mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
client: rename all instances of sha256.New() to hash256 so they dont collide with the package name
Signed-off-by: karo <karolin.kostial@gmail.com>
This commit is contained in:
@@ -279,7 +279,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
}
|
||||
|
||||
// Hashing
|
||||
hashSHA256 := sha256.New()
|
||||
hash256 := sha256.New()
|
||||
|
||||
// Deal with split images
|
||||
if ctype == "multipart/form-data" {
|
||||
@@ -300,7 +300,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
return nil, fmt.Errorf("Invalid multipart image")
|
||||
}
|
||||
|
||||
size, err := io.Copy(io.MultiWriter(req.MetaFile, hashSHA256), part)
|
||||
size, err := io.Copy(io.MultiWriter(req.MetaFile, hash256), part)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -318,7 +318,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
return nil, fmt.Errorf("Invalid multipart image")
|
||||
}
|
||||
|
||||
size, err = io.Copy(io.MultiWriter(req.RootfsFile, hashSHA256), part)
|
||||
size, err = io.Copy(io.MultiWriter(req.RootfsFile, hash256), part)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -327,7 +327,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
resp.RootfsName = part.FileName()
|
||||
|
||||
// Check the hash
|
||||
hash := fmt.Sprintf("%x", hashSHA256.Sum(nil))
|
||||
hash := fmt.Sprintf("%x", hash256.Sum(nil))
|
||||
if imageType != "oci" && !strings.HasPrefix(hash, fingerprint) {
|
||||
return nil, fmt.Errorf("Image fingerprint doesn't match. Got %s expected %s", hash, fingerprint)
|
||||
}
|
||||
@@ -346,7 +346,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
return nil, fmt.Errorf("No filename in Content-Disposition header")
|
||||
}
|
||||
|
||||
size, err := io.Copy(io.MultiWriter(req.MetaFile, hashSHA256), body)
|
||||
size, err := io.Copy(io.MultiWriter(req.MetaFile, hash256), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func incusDownloadImage(fingerprint string, uri string, userAgent string, do fun
|
||||
resp.MetaName = filename
|
||||
|
||||
// Check the hash
|
||||
hash := fmt.Sprintf("%x", hashSHA256.Sum(nil))
|
||||
hash := fmt.Sprintf("%x", hash256.Sum(nil))
|
||||
if imageType != "oci" && !strings.HasPrefix(hash, fingerprint) {
|
||||
return nil, fmt.Errorf("Image fingerprint doesn't match. Got %s expected %s", hash, fingerprint)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user