Skip to content

Commit

Permalink
Pass the expected string to NewSha256Verifier().
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Apr 26, 2016
1 parent 280786d commit fd624c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions downloader/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ func NewHTTPBlobOpener(hostnameVerification utils.SSLHostnameVerification) func(
// NewSha256Verifier returns a verifier suitable for Request. The
// verifier checks the SHA-256 checksum of the file to ensure that it
// matches the one returned by the provided func.
func NewSha256Verifier(getExpected func() (string, error)) func(*os.File) error {
func NewSha256Verifier(expected string) func(*os.File) error {
return func(file *os.File) error {
expected, err := getExpected()
if err != nil {
return errors.Trace(err)
}

actual, _, err := utils.ReadSHA256(file)
if err != nil {
return errors.Trace(err)
Expand Down
3 changes: 2 additions & 1 deletion worker/uniter/charm/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ func (d *BundlesDir) download(info BundleInfo, target string, abort <-chan struc
if err != nil {
return errors.Annotate(err, "could not parse charm URL")
}
expectedSha256, err := info.ArchiveSha256()
req := downloader.Request{
URL: curl,
TargetDir: d.downloadsPath(),
Verify: downloader.NewSha256Verifier(info.ArchiveSha256),
Verify: downloader.NewSha256Verifier(expectedSha256),
}
logger.Infof("downloading %s from API server", info.URL())
filename, err := d.downloader.Download(req, abort)
Expand Down

0 comments on commit fd624c5

Please sign in to comment.