Fixed SPM being stuck in loop if up-to-date package is already installed
All checks were successful
/ test-on-windows (push) Successful in 6s
/ test-on-alpine (push) Successful in 5s

This commit is contained in:
Internet Addict 2025-02-13 09:41:21 +00:00
parent b1e39f52ac
commit 5691c2b46c

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
) )
// pendingUpdates holds info about packages that have been downloaded/decompressed // pendingUpdates holds info about packages that have been downloaded/decompressed
@ -82,11 +83,24 @@ func AutoDownloadUpdates() error {
// 5) Download the package into a temporary download folder // 5) Download the package into a temporary download folder
downloadDir := GetTempDir() downloadDir := GetTempDir()
fmt.Printf("[INFO] Downloading package '%s' to temporary folder: %s\n", matchingEntry.Name, downloadDir) fmt.Printf("[INFO] Downloading package '%s' to temporary folder: %s\n",
matchingEntry.Name, downloadDir)
err = DownloadPackageFromAppIndex(appIndexPath, matchingEntry.Name, matchingEntry.Release, matchingEntry.Type, downloadDir) err = DownloadPackageFromAppIndex(
appIndexPath,
matchingEntry.Name,
matchingEntry.Release,
matchingEntry.Type,
downloadDir,
)
if err != nil { if err != nil {
return fmt.Errorf("[ERROR] Failed to download package '%s': %w", matchingEntry.Name, err) // If the package is already up-to-date, skip it instead of erroring out
if strings.Contains(err.Error(), "Already up-to-date") {
fmt.Printf("[INFO] Package '%s' is already up-to-date, skipping.\n", matchingEntry.Name)
continue
}
return fmt.Errorf("[ERROR] Failed to download package '%s': %w",
matchingEntry.Name, err)
} }
fmt.Printf("[INFO] Package '%s' downloaded successfully to: %s\n", matchingEntry.Name, downloadDir) fmt.Printf("[INFO] Package '%s' downloaded successfully to: %s\n", matchingEntry.Name, downloadDir)
@ -223,7 +237,8 @@ func AutoDownloadSpecified(specs []AppIndexEntry) error {
// 5) Download the package // 5) Download the package
downloadDir := GetTempDir() downloadDir := GetTempDir()
fmt.Printf("[INFO] Downloading package '%s' to temporary folder: %s\n", matchingEntry.Name, downloadDir) fmt.Printf("[INFO] Downloading package '%s' to temporary folder: %s\n",
matchingEntry.Name, downloadDir)
if err := DownloadPackageFromAppIndex( if err := DownloadPackageFromAppIndex(
appIndexPath, appIndexPath,
matchingEntry.Name, matchingEntry.Name,
@ -231,7 +246,13 @@ func AutoDownloadSpecified(specs []AppIndexEntry) error {
matchingEntry.Type, matchingEntry.Type,
downloadDir, downloadDir,
); err != nil { ); err != nil {
return fmt.Errorf("[ERROR] Failed to download package '%s': %w", matchingEntry.Name, err) // Again, if "Already up-to-date", skip
if strings.Contains(err.Error(), "Already up-to-date") {
fmt.Printf("[INFO] Package '%s' is already up-to-date, skipping.\n", matchingEntry.Name)
continue
}
return fmt.Errorf("[ERROR] Failed to download package '%s': %w",
matchingEntry.Name, err)
} }
fmt.Printf("[INFO] Package '%s' downloaded successfully to: %s\n", matchingEntry.Name, downloadDir) fmt.Printf("[INFO] Package '%s' downloaded successfully to: %s\n", matchingEntry.Name, downloadDir)