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

fs/operations: add server-side moves to stats

Ole Frost3c2252b7c002
diff --git a/fs/operations/operations.go b/fs/operations/operations.go
index bc5832b59..dcf296b90 100644
--- a/fs/operations/operations.go
+++ b/fs/operations/operations.go
@@ -405,7 +405,7 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj
if err == nil {
dst = newDst
in.ServerSideCopyEnd(dst.Size()) // account the bytes for the server-side transfer
- err = in.Close()
+ _ = in.Close()
} else {
_ = in.Close()
}
@@ -598,6 +598,8 @@ func Move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs.
}
}
// Move dst <- src
+ in := tr.Account(ctx, nil) // account the transfer
+ in.ServerSideCopyStart()
newDst, err = doMove(ctx, src, remote)
switch err {
case nil:
@@ -606,13 +608,16 @@ func Move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs.
} else {
fs.Infof(src, "Moved (server-side)")
}
-
+ in.ServerSideCopyEnd(newDst.Size()) // account the bytes for the server-side transfer
+ _ = in.Close()
return newDst, nil
case fs.ErrorCantMove:
fs.Debugf(src, "Can't move, switching to copy")
+ _ = in.Close()
default:
err = fs.CountError(err)
fs.Errorf(src, "Couldn't move: %v", err)
+ _ = in.Close()
return newDst, err
}
}