@@ -279,7 +279,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
279279 }
280280
281281 // Hashing
282- hashSHA256 := sha256 .New ()
282+ hash256 := sha256 .New ()
283283
284284 // Deal with split images
285285 if ctype == "multipart/form-data" {
@@ -300,7 +300,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
300300 return nil , fmt .Errorf ("Invalid multipart image" )
301301 }
302302
303- size , err := io .Copy (io .MultiWriter (req .MetaFile , hashSHA256 ), part )
303+ size , err := io .Copy (io .MultiWriter (req .MetaFile , hash256 ), part )
304304 if err != nil {
305305 return nil , err
306306 }
@@ -318,7 +318,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
318318 return nil , fmt .Errorf ("Invalid multipart image" )
319319 }
320320
321- size , err = io .Copy (io .MultiWriter (req .RootfsFile , hashSHA256 ), part )
321+ size , err = io .Copy (io .MultiWriter (req .RootfsFile , hash256 ), part )
322322 if err != nil {
323323 return nil , err
324324 }
@@ -327,7 +327,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
327327 resp .RootfsName = part .FileName ()
328328
329329 // Check the hash
330- hash := fmt .Sprintf ("%x" , hashSHA256 .Sum (nil ))
330+ hash := fmt .Sprintf ("%x" , hash256 .Sum (nil ))
331331 if imageType != "oci" && ! strings .HasPrefix (hash , fingerprint ) {
332332 return nil , fmt .Errorf ("Image fingerprint doesn't match. Got %s expected %s" , hash , fingerprint )
333333 }
@@ -346,7 +346,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
346346 return nil , fmt .Errorf ("No filename in Content-Disposition header" )
347347 }
348348
349- size , err := io .Copy (io .MultiWriter (req .MetaFile , hashSHA256 ), body )
349+ size , err := io .Copy (io .MultiWriter (req .MetaFile , hash256 ), body )
350350 if err != nil {
351351 return nil , err
352352 }
@@ -355,7 +355,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
355355 resp .MetaName = filename
356356
357357 // Check the hash
358- hash := fmt .Sprintf ("%x" , hashSHA256 .Sum (nil ))
358+ hash := fmt .Sprintf ("%x" , hash256 .Sum (nil ))
359359 if imageType != "oci" && ! strings .HasPrefix (hash , fingerprint ) {
360360 return nil , fmt .Errorf ("Image fingerprint doesn't match. Got %s expected %s" , hash , fingerprint )
361361 }
0 commit comments