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

fstests: allow ObjectUpdate test to retry upload

Nick Craig-Woodf7665300c0f6
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index ddd20c97a..99ec177b8 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -1516,19 +1516,21 @@ func Run(t *testing.T, opt *Opt) {
t.Run("ObjectUpdate", func(t *testing.T) {
skipIfNotOk(t)
contents := random.String(200)
- buf := bytes.NewBufferString(contents)
- hash := hash.NewMultiHasher()
- in := io.TeeReader(buf, hash)
+ var h *hash.MultiHasher
- file1.Size = int64(buf.Len())
+ file1.Size = int64(len(contents))
obj := findObject(ctx, t, f, file1.Path)
remoteBefore := obj.Remote()
obji := object.NewStaticObjectInfo(file1.Path+"-should-be-ignored.bin", file1.ModTime, int64(len(contents)), true, nil, obj.Fs())
- err := obj.Update(ctx, in, obji)
- require.NoError(t, err)
+ retry(t, "Update object", func() error {
+ buf := bytes.NewBufferString(contents)
+ h = hash.NewMultiHasher()
+ in := io.TeeReader(buf, h)
+ return obj.Update(ctx, in, obji)
+ })
remoteAfter := obj.Remote()
assert.Equal(t, remoteBefore, remoteAfter, "Remote should not change")
- file1.Hashes = hash.Sums()
+ file1.Hashes = h.Sums()
// check the object has been updated
file1.Check(t, obj, f.Precision())