Skip to content

Commit

Permalink
fix: windows install errors on decompressing zip archive
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Jan 29, 2024
1 parent 6a37e39 commit 5323b9f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/resticinstaller/resticinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,15 @@ func downloadFile(url string, downloadPath string) (string, error) {
hash := sha256.Sum256(body)

if strings.HasSuffix(url, ".bz2") {
zap.S().Infof("Decompressing bz2 archive (size=%v)...", len(body))
body, err = io.ReadAll(bzip2.NewReader(bytes.NewReader(body)))
if err != nil {
return "", fmt.Errorf("bz2 decompress body: %w", err)
}
} else if strings.HasSuffix(url, ".zip") {
var fullBody bytes.Buffer
_, err := io.Copy(&fullBody, resp.Body)
if err != nil {
return "", fmt.Errorf("copy response body to buffer: %w", err)
}
zap.S().Infof("Decompressing zip archive (size=%v)...", len(body))

archive, err := zip.NewReader(bytes.NewReader(fullBody.Bytes()), int64(fullBody.Len()))
archive, err := zip.NewReader(bytes.NewReader(body), int64(len(body)))
if err != nil {
return "", fmt.Errorf("open zip archive: %w", err)
}
Expand Down

0 comments on commit 5323b9f

Please sign in to comment.