diff --git a/storage/filesystem.go b/storage/filesystem.go index 6f3a189..24f8465 100644 --- a/storage/filesystem.go +++ b/storage/filesystem.go @@ -2,10 +2,11 @@ package storage import ( "context" - "crypto/md5" + "crypto/sha1" "encoding/base64" "encoding/json" "fmt" + "io" "io/ioutil" "os" "path/filepath" @@ -75,11 +76,18 @@ func (b *filesystemBackend) safePath(ctx context.Context, path string) (string, } func etagForFile(path string) (string, error) { - data, err := ioutil.ReadFile(path) + f, err := os.Open(path) if err != nil { return "", err } - csum := md5.Sum(data) + defer f.Close() + + h := sha1.New() + if _, err := io.Copy(h, f); err != nil { + return "", err + } + csum := h.Sum(nil) + return base64.StdEncoding.EncodeToString(csum[:]), nil }