diff --git a/go.mod b/go.mod index 9020865..dd3f66b 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b require ( github.com/ebitengine/purego v0.7.1 // indirect + github.com/stretchr/testify v1.10.0 // indirect golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect golang.org/x/sys v0.20.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index fcea25d..c7bf812 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,18 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA= github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b h1:JJfspevP3YOXcSKVABizYOv++yMpTJIdPUtoDzF/RWw= github.com/gen2brain/raylib-go/raylib v0.0.0-20250109172833-6dbba4f81a9b/go.mod h1:BaY76bZk7nw1/kVOSQObPY1v1iwVE1KHAGMfvI6oK1Q= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/spm/auto.go b/spm/auto.go index 92e574a..66b7366 100644 --- a/spm/auto.go +++ b/spm/auto.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" ) // 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 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 { - 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) @@ -223,7 +237,8 @@ func AutoDownloadSpecified(specs []AppIndexEntry) error { // 5) Download the package 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( appIndexPath, matchingEntry.Name, @@ -231,7 +246,13 @@ func AutoDownloadSpecified(specs []AppIndexEntry) error { matchingEntry.Type, downloadDir, ); 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)