Skip to content

Commit

Permalink
fix(cli): try to download and verify binary up to 3 times, add small
Browse files Browse the repository at this point in the history
delay between tries
  • Loading branch information
pascalbreuninger committed Dec 5, 2024
1 parent 3fe6095 commit a399a52
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/binaries/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"

"github.com/loft-sh/devpod/pkg/config"
"github.com/loft-sh/devpod/pkg/copy"
Expand Down Expand Up @@ -84,7 +85,7 @@ func DownloadBinaries(binaries map[string][]*provider2.ProviderBinary, targetFol
}

// try to download the binary
for i := 0; i < 2; i++ {
for i := 0; i < 3; i++ {
binaryPath, err := downloadBinary(binaryName, binary, targetFolder, log)
if err != nil {
return nil, errors.Wrapf(err, "downloading binary %s", binaryName)
Expand All @@ -99,6 +100,7 @@ func DownloadBinaries(binaries map[string][]*provider2.ProviderBinary, targetFol
} else if !strings.EqualFold(fileHash, binary.Checksum) {
_ = os.Remove(binaryPath)
log.Errorf("Unexpected file checksum %s != %s for binary %s", strings.ToLower(fileHash), strings.ToLower(binary.Checksum), binaryName)
time.Sleep(250 * time.Millisecond)
continue
}
}
Expand Down

0 comments on commit a399a52

Please sign in to comment.