Skip to content

Commit 79cc2d6

Browse files
Copilotbgn42
andauthored
Fix progress reporting and redundant assignment in DownloadPDSCFiles
Agent-Logs-Url: https://github.com/Open-CMSIS-Pack/cpackget/sessions/8327d776-f919-4106-9979-0892fca6c310 Co-authored-by: bgn42 <92579424+bgn42@users.noreply.github.com>
1 parent 12a3296 commit 79cc2d6

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cmd/installer/root.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ func CheckConcurrency(concurrency int) int {
674674
//
675675
// Parameters:
676676
// - skipInstalledPdscFiles: If true, skips downloading PDSC files that are already installed.
677+
// - skipDeprecatedPdscFiles: If true, skips downloading PDSC files that are marked as deprecated.
677678
// - insecureSkipVerify: If true, skips TLS certificate verification for HTTPS downloads.
678679
// - concurrency: The number of concurrent downloads to allow. If 0, downloads are sequential.
679680
// - timeout: The timeout for each download operation.
@@ -686,7 +687,21 @@ func DownloadPDSCFiles(skipInstalledPdscFiles, skipDeprecatedPdscFiles, insecure
686687
// return err
687688
// }
688689

689-
pdscTags := Installation.PublicIndexXML.ListPdscTags()
690+
allPdscTags := Installation.PublicIndexXML.ListPdscTags()
691+
692+
// Filter out deprecated tags upfront if requested, so the job count
693+
// used for progress reporting matches the actual number of downloads.
694+
var pdscTags []xml.PdscTag
695+
if skipDeprecatedPdscFiles {
696+
for _, t := range allPdscTags {
697+
if !t.IsDeprecated() {
698+
pdscTags = append(pdscTags, t)
699+
}
700+
}
701+
} else {
702+
pdscTags = allPdscTags
703+
}
704+
690705
numPdsc := len(pdscTags)
691706
if numPdsc == 0 {
692707
log.Info("(no packs in public index)")
@@ -704,9 +719,6 @@ func DownloadPDSCFiles(skipInstalledPdscFiles, skipDeprecatedPdscFiles, insecure
704719
var errTags lockedSlice
705720

706721
for _, pdscTag := range pdscTags {
707-
if skipDeprecatedPdscFiles && pdscTag.IsDeprecated() {
708-
continue
709-
}
710722
if concurrency == 0 {
711723
massDownloadPdscFiles(pdscTag, skipInstalledPdscFiles, true, insecureSkipVerify, timeout, &errTags)
712724
} else {
@@ -1228,17 +1240,18 @@ func ListInstalledPacks(listCached, listPublic, listUpdates, listDeprecated, lis
12281240
})
12291241
// List all available packs from the index
12301242
for _, pdscTag := range pdscTags {
1243+
isDeprecated := pdscTag.IsDeprecated()
12311244
// Filter by deprecated status:
12321245
// --deprecated: show only deprecated packs
12331246
// without --deprecated: hide deprecated packs
1234-
if listDeprecated && !pdscTag.IsDeprecated() {
1247+
if listDeprecated && !isDeprecated {
12351248
continue
12361249
}
1237-
if !listDeprecated && pdscTag.IsDeprecated() {
1250+
if !listDeprecated && isDeprecated {
12381251
continue
12391252
}
12401253
logMessage := pdscTag.YamlPackID()
1241-
if pdscTag.IsDeprecated() {
1254+
if isDeprecated {
12421255
logMessage += " (deprecated)"
12431256
}
12441257
packFilePath := filepath.Join(Installation.DownloadDir, pdscTag.Key()) + utils.PackExtension

0 commit comments

Comments
 (0)