mirror of
https://github.com/restic/restic.git
synced 2025-10-09 07:33:53 +00:00
gs/swift: calculate md5 content hash for upload
This commit is contained in:
@@ -3,6 +3,7 @@ package gs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"hash"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -191,7 +192,7 @@ func (be *Backend) Location() string {
|
||||
|
||||
// Hasher may return a hash function for calculating a content hash for the backend
|
||||
func (be *Backend) Hasher() hash.Hash {
|
||||
return nil
|
||||
return md5.New()
|
||||
}
|
||||
|
||||
// Path returns the path in the bucket that is used for this backend.
|
||||
@@ -240,6 +241,7 @@ func (be *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRe
|
||||
// uploads are not providing significant benefit anyways.
|
||||
w := be.bucket.Object(objName).NewWriter(ctx)
|
||||
w.ChunkSize = 0
|
||||
w.MD5 = rd.Hash()
|
||||
wbytes, err := io.Copy(w, rd)
|
||||
cerr := w.Close()
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user