This commit is contained in:
partisan 2025-03-01 17:59:26 +01:00
parent 66f4191c5f
commit 44d20eb983
10 changed files with 319 additions and 72 deletions

View file

@ -11,9 +11,9 @@ import (
)
// DownloadPackageFromAppIndex selects and downloads the correct package from the APPINDEX.
func DownloadPackageFromAppIndex(appIndexPath string, packageName string, release string, pkgType string, destDir string) error {
func DownloadPackageFromAppIndex(packageName string, release string, pkgType string, destDir string) error {
// Parse the APPINDEX
entries, err := ParseAppIndex(appIndexPath)
entries, err := GetIndex()
if err != nil {
return fmt.Errorf("failed to parse APPINDEX: %w", err)
}
@ -99,8 +99,8 @@ func DownloadPackageFromAppIndex(appIndexPath string, packageName string, releas
expectedFilePath := filepath.Join(destDir, expectedFileName)
// I dont know why is this happening, I dont want to know but sometimes some process is helding up the donwloaded files so thats why it retries here
maxRetries := 5
// I dont know why is this happening, I dont want to know but sometimes some process is helding up the downloaded files so thats why it retries here
maxRetries := 10
for i := 0; i < maxRetries; i++ {
err = os.Rename(downloadedFilePath, expectedFilePath)
if err == nil {
@ -115,7 +115,7 @@ func DownloadPackageFromAppIndex(appIndexPath string, packageName string, releas
f.Close()
if i < maxRetries-1 {
time.Sleep(500 * time.Millisecond) // Wait before retrying
time.Sleep(250 * time.Millisecond) // Wait before retrying
}
}