Fixed SPM being stuck in loop if up-to-date package is already installed
This commit is contained in:
parent
b1e39f52ac
commit
5691c2b46c
1 changed files with 282 additions and 261 deletions
31
spm/auto.go
31
spm/auto.go
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue