Skip to content

Commit

Permalink
[DATA-1255] Use base64.StdEncoding on the crc32 hash on deployed files (
Browse files Browse the repository at this point in the history
  • Loading branch information
agreenb authored Mar 22, 2023
1 parent b1208fb commit 19683d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions robot/packages/cloud_package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ func (m *cloudManager) downloadFileFromGCSURL(ctx context.Context, url string, p
return checksum, contentType, err
}

outHash := base64.URLEncoding.EncodeToString(hash.Sum(nil))
outHash := base64.StdEncoding.EncodeToString(hash.Sum(nil))
if outHash != checksum {
utils.UncheckedError(os.Remove(downloadPath))
return checksum, contentType, errors.Errorf("download did not match expected hash %s != %s", outHash, checksum)
return checksum, contentType, errors.Errorf("download did not match expected hash %s != %s", checksum, outHash)
}

return checksum, contentType, nil
Expand Down
8 changes: 4 additions & 4 deletions robot/packages/testutils/fake_package_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ func ValidateContentsOfPPackage(t *testing.T, dir string) {

expected := []content{
{path: "some-link.txt", isLink: true, linkTarget: "sub-dir/sub-file.txt"},
{path: "some-text.txt", checksum: "p_E54w=="},
{path: "some-text2.txt", checksum: "p_E54w=="},
{path: "some-text.txt", checksum: "p/E54w=="},
{path: "some-text2.txt", checksum: "p/E54w=="},
{path: "sub-dir", isDir: true},
{path: "sub-dir/sub-file.txt", checksum: "p_E54w=="},
{path: "sub-dir/sub-file.txt", checksum: "p/E54w=="},
{path: "sub-dir-link", isLink: true, linkTarget: "sub-dir"},
}

Expand Down Expand Up @@ -394,7 +394,7 @@ func checksumFile(path string) (string, error) {
return "", err
}

return base64.URLEncoding.EncodeToString(hasher.Sum(nil)), nil
return base64.StdEncoding.EncodeToString(hasher.Sum(nil)), nil
}

func crc32Hash() hash.Hash32 {
Expand Down

0 comments on commit 19683d8

Please sign in to comment.