Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(300)

Unified Diff: charm/repo.go

Issue 53210044: state;apiserver: Fix a race - lp bug #1067979 (Closed)
Patch Set: state;apiserver: Fix a race - lp bug #1067979 Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | charm/testing/mockstore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: charm/repo.go
=== modified file 'charm/repo.go'
--- charm/repo.go 2014-01-22 16:48:19 +0000
+++ charm/repo.go 2014-01-28 17:07:55 +0000
@@ -4,8 +4,6 @@
package charm
import (
- "crypto/sha256"
- "encoding/hex"
"encoding/json"
"fmt"
"io"
@@ -299,16 +297,11 @@
// verify returns an error unless a file exists at path with a hex-encoded
// SHA256 matching digest.
func verify(path, digest string) error {
- f, err := os.Open(path)
+ hash, _, err := utils.ReadFileSHA256(path)
if err != nil {
return err
}
- defer f.Close()
- h := sha256.New()
- if _, err := io.Copy(h, f); err != nil {
- return err
- }
- if hex.EncodeToString(h.Sum(nil)) != digest {
+ if hash != digest {
return fmt.Errorf("bad SHA256 of %q", path)
}
return nil
« no previous file with comments | « [revision details] ('k') | charm/testing/mockstore.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b