@@ -391,7 +391,7 @@ func RemovePdsc(pdscPath string) error {
391391//
392392// massDownloadPdscFiles(pdscTag, true, 30)
393393func massDownloadPdscFiles (pdscTag xml.PdscTag , skipInstalledPdscFiles bool , timeout int , errTags * lockedSlice ) {
394- if err := Installation .downloadPdscFile (pdscTag , skipInstalledPdscFiles , timeout ); err != nil {
394+ if err := Installation .downloadPdscFile (pdscTag , skipInstalledPdscFiles , true , timeout ); err != nil {
395395 errTags .lock .Lock ()
396396 errTags .slice = append (errTags .slice , pdscTag )
397397 errTags .lock .Unlock ()
@@ -832,7 +832,7 @@ func UpdatePublicIndexIfOnline() error {
832832// - overwrite: A boolean flag to indicate whether to overwrite the existing public index. This will be removed in future versions.
833833// - sparse: A boolean flag to indicate whether to perform a sparse update.
834834// - downloadPdsc: A boolean flag to indicate whether to download PDSC files.
835- // - downloadRemainingPdscFiles: A boolean flag to indicate whether to download remaining PDSC files.
835+ // - downloadRemainingPdscFiles: A boolean flag to indicate whether to download all remaining PDSC files.
836836// - concurrency: The number of concurrent operations allowed.
837837// - timeout: The timeout duration for network operations.
838838//
@@ -871,7 +871,7 @@ func UpdatePublicIndex(indexPath string, overwrite bool, sparse bool, downloadPd
871871 log .Warnf ("Non-HTTPS url: \" %s\" " , indexPath )
872872 }
873873
874- indexPath , err = utils .DownloadFile (indexPath , timeout )
874+ indexPath , err = utils .DownloadFile (indexPath , false , timeout )
875875 if err != nil {
876876 return err
877877 }
@@ -1306,14 +1306,14 @@ func FindPackURL(pack *PackType) (string, error) {
13061306 })
13071307 if len (tags ) != 0 {
13081308 tags [0 ].Version = ""
1309- if err := Installation .downloadPdscFile (tags [0 ], true , 0 ); err != nil {
1309+ if err := Installation .downloadPdscFile (tags [0 ], true , false , 0 ); err != nil {
13101310 return "" , err
13111311 }
13121312 } else {
13131313 return "" , errs .ErrPdscEntryNotFound
13141314 }
13151315 } else {
1316- if err := Installation .downloadPdscFile (xml.PdscTag {URL : pack .URL , Vendor : pack .Vendor , Name : pack .Name }, true , 0 ); err != nil {
1316+ if err := Installation .downloadPdscFile (xml.PdscTag {URL : pack .URL , Vendor : pack .Vendor , Name : pack .Name }, true , false , 0 ); err != nil {
13171317 return "" , err
13181318 }
13191319 }
@@ -1861,18 +1861,25 @@ func (p *PacksInstallationType) packIsPublic(pack *PackType, pdscTag *xml.PdscTa
18611861 return true , nil
18621862}
18631863
1864- // downloadPdscFile downloads a PDSC file based on the provided pdscTag and saves it to the specified location.
1865- // If skipInstalledPdscFiles is true and the file already exists, the function will skip the download.
1866- // The function also handles switching to a cache URL if necessary and ensures the file is moved to the correct location.
1864+ // downloadPdscFile downloads a PDSC (Pack Description) file from a specified URL and saves it to the local file system.
1865+ // It handles scenarios such as skipping already installed files, switching to a cache URL, and managing file permissions.
18671866//
18681867// Parameters:
1869- // - pdscTag: An xml.PdscTag containing the vendor, name, and URL of the PDSC file.
1870- // - skipInstalledPdscFiles: A boolean indicating whether to skip downloading if the file already exists.
1871- // - timeout: An integer specifying the timeout duration for the download.
1868+ // - pdscTag: An xml.PdscTag object containing metadata about the PDSC file to be downloaded.
1869+ // - skipInstalledPdscFiles: A boolean flag indicating whether to skip downloading if the PDSC file already exists locally.
1870+ // - noProgressBar: A boolean flag indicating whether to suppress the progress bar during the download.
1871+ // - timeout: An integer specifying the timeout duration (in seconds) for the download operation.
18721872//
18731873// Returns:
1874- // - error: An error if any issues occur during the download or file operations.
1875- func (p * PacksInstallationType ) downloadPdscFile (pdscTag xml.PdscTag , skipInstalledPdscFiles bool , timeout int ) error {
1874+ // - error: An error object if any issues occur during the download or file operations, or nil if the operation succeeds.
1875+ //
1876+ // Behavior:
1877+ // - If skipInstalledPdscFiles is true and the file already exists locally, the function returns without downloading.
1878+ // - If the PDSC file's URL is not the default Keil pack root and the public index XML URL matches the default root,
1879+ // the function switches to the cache URL for downloading.
1880+ // - The function downloads the PDSC file, temporarily saves it, and then moves it to the target location,
1881+ // ensuring proper file permissions are set before and after the operation.
1882+ func (p * PacksInstallationType ) downloadPdscFile (pdscTag xml.PdscTag , skipInstalledPdscFiles , noProgressBar bool , timeout int ) error {
18761883 basePdscFile := fmt .Sprintf ("%s.pdsc" , pdscTag .VName ())
18771884 pdscFilePath := filepath .Join (p .WebDir , basePdscFile )
18781885
@@ -1902,7 +1909,7 @@ func (p *PacksInstallationType) downloadPdscFile(pdscTag xml.PdscTag, skipInstal
19021909
19031910 pdscFileURL .Path = path .Join (pdscFileURL .Path , basePdscFile )
19041911
1905- localFileName , err := utils .DownloadFile (pdscFileURL .String (), timeout )
1912+ localFileName , err := utils .DownloadFile (pdscFileURL .String (), noProgressBar , timeout )
19061913 defer os .Remove (localFileName )
19071914
19081915 if err != nil {
@@ -1964,7 +1971,7 @@ func (p *PacksInstallationType) loadPdscFile(pdscTag xml.PdscTag, timeout int) e
19641971 return nil
19651972 }
19661973
1967- localFileName , err := utils .DownloadFile (pdscFileURL .String (), timeout )
1974+ localFileName , err := utils .DownloadFile (pdscFileURL .String (), false , timeout )
19681975 defer os .Remove (localFileName )
19691976
19701977 if err != nil {
0 commit comments