From 2aa9a11dd45fd06b85d1c89b56ba4aa348e85cda Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Thu, 25 Nov 2021 11:07:00 +0100 Subject: [PATCH] sources: Fix downloads with multiple hashes Signed-off-by: Thomas Hipp --- sources/common.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sources/common.go b/sources/common.go index 7a63562a..94b35971 100644 --- a/sources/common.go +++ b/sources/common.go @@ -144,23 +144,23 @@ func (s *common) DownloadHash(def shared.DefinitionImage, file, checksum string, }, 3) } else { // Check all file hashes in case multiple have been provided. - for _, h := range hashes { - if hashFunc != nil { - hashFunc.Reset() - } + err = shared.Retry(func() error { + for _, h := range hashes { + if hashFunc != nil { + hashFunc.Reset() + } - err = shared.Retry(func() error { _, err = lxd.DownloadFileHash(s.ctx, &client, "", progress, nil, imagePath, file, h, hashFunc, image) - if err != nil { - os.Remove(imagePath) + if err == nil { + break } - - return err - }, 3) - if err == nil { - break } - } + if err != nil { + os.Remove(imagePath) + } + + return err + }, 3) } if err != nil { return "", err