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

filescom: fix missing MD5 hash after uploading a file

Nick Craig-Wood3e190326564f
diff --git a/backend/filescom/filescom.go b/backend/filescom/filescom.go
index 38807d03a..62d0f432d 100644
--- a/backend/filescom/filescom.go
+++ b/backend/filescom/filescom.go
@@ -866,7 +866,24 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
return err
}
- return o.readMetaData(ctx)
+ // The server computes the MD5 asynchronously after upload so
+ // retry reading the metadata for a short time until it appears.
+ const maxTries = 10
+ for tries := 1; ; tries++ {
+ err = o.readMetaData(ctx)
+ if err != nil {
+ return err
+ }
+ if o.md5 != "" || tries >= maxTries {
+ break
+ }
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-time.After(time.Duration(tries) * 100 * time.Millisecond):
+ }
+ }
+ return nil
}
// Remove an object