filescom: fix missing MD5 hash after uploading a file

The server computes the MD5 checksum asynchronously after upload, so
the object returned from Put and Update often had no MD5 while a
fresh listing shortly afterwards would report one. This broke
wrappers which compare exact hashes, such as the hasher backend's
fingerprint and the VFS cache. Retry reading the metadata for a short
time after upload until the MD5 appears.
This commit is contained in:
Nick Craig-Wood
2026-07-14 14:13:49 +01:00
parent 57b1f24566
commit 3e19032656
+18 -1
View File
@@ -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