netstorage: fix missing MD5 hash after uploading a file
The object returned from Put and Update had an empty MD5 checksum while a fresh listing would report the MD5 the server computed for the upload. This broke wrappers which compare exact hashes, such as the hasher backend's fingerprint and the VFS cache. Stat the file after upload to pick up the server computed MD5.
This commit is contained in:
@@ -1050,14 +1050,15 @@ func (o *Object) netStorageUploadRequest(ctx context.Context, in io.Reader, src
|
|||||||
|
|
||||||
// Invalidate stat cache
|
// Invalidate stat cache
|
||||||
o.fs.deleteStatCache(URL)
|
o.fs.deleteStatCache(URL)
|
||||||
if o.size == -1 {
|
// 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)
|
files, err := o.fs.netStorageStatRequest(ctx, URL, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if files != nil {
|
if files != nil {
|
||||||
o.size = files[0].Size
|
o.size = files[0].Size
|
||||||
}
|
o.md5sum = files[0].Md5
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user