Skip to content

Commit

Permalink
shorter code for sha calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
encryptio committed Dec 13, 2015
1 parent f6bd2cc commit 695e6f7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,14 @@ func (be *B2Ext) Store(e *external.External, key, file string) error {
defer close(shaReady)

sha := sha1.New()
n, err := io.Copy(sha, fh)
if err != nil {
shaError = err
return
}
contentLength = n

_, err = fh.Seek(0, 0)
if err != nil {
shaError = err
contentLength, shaError = io.Copy(sha, fh)
if shaError != nil {
return
}

haveSHA = sha.Sum(nil)

_, shaError = fh.Seek(0, 0)
}()

res, err := be.bucket.ListFileNames(be.prefix+key, 1)
Expand Down

0 comments on commit 695e6f7

Please sign in to comment.