Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

netstorage: fix missing MD5 hash after uploading a file

Nick Craig-Wood57b1f24566a8
diff --git a/backend/netstorage/netstorage.go b/backend/netstorage/netstorage.go
index 812eb1e27..cbc029ad9 100755
--- a/backend/netstorage/netstorage.go
+++ b/backend/netstorage/netstorage.go
@@ -1050,14 +1050,15 @@ func (o *Object) netStorageUploadRequest(ctx context.Context, in io.Reader, src
// Invalidate stat cache
o.fs.deleteStatCache(URL)
- if o.size == -1 {
- files, err := o.fs.netStorageStatRequest(ctx, URL, false)
- if err != nil {
- return nil
- }
- if files != nil {
- o.size = files[0].Size
- }
+ // Stat the uploaded file to get the md5 the server computed and
+ // the size for streaming uploads.
+ files, err := o.fs.netStorageStatRequest(ctx, URL, false)
+ if err != nil {
+ return nil
+ }
+ if files != nil {
+ o.size = files[0].Size
+ o.md5sum = files[0].Md5
}
return nil
}