From cd0ca6c1bfbdc704f6a994db679978f33af82bf4 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Mon, 29 Jan 2024 01:33:47 -0800 Subject: [PATCH] fix: windows install errors on decompressing zip archive --- internal/resticinstaller/resticinstaller.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/resticinstaller/resticinstaller.go b/internal/resticinstaller/resticinstaller.go index 4009f460..bf32f6b7 100644 --- a/internal/resticinstaller/resticinstaller.go +++ b/internal/resticinstaller/resticinstaller.go @@ -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) }