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

Add ServerSideAcrossConfig Flag and check for it. fixes #2728

Fionera55b9a4ed309f
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index f60e0ba2f..dc6ea4c8c 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -907,6 +907,7 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) {
ReadMimeType: true,
WriteMimeType: true,
CanHaveEmptyDirectories: true,
+ ServerSideAcrossConfigs: true,
}).Fill(f)
// Create a new authorized Drive client.
diff --git a/fs/fs.go b/fs/fs.go
index 0b1cd5b2a..a25eb1039 100644
--- a/fs/fs.go
+++ b/fs/fs.go
@@ -409,6 +409,7 @@ type Features struct {
BucketBased bool // is bucket based (like s3, swift etc)
SetTier bool // allows set tier functionality on objects
GetTier bool // allows to retrieve storage tier of objects
+ ServerSideAcrossConfigs bool // can server side copy between different remotes of the same type
// Purge all files in the root and the root directory
//
diff --git a/fs/operations/operations.go b/fs/operations/operations.go
index ec2be9290..f10f7f67b 100644
--- a/fs/operations/operations.go
+++ b/fs/operations/operations.go
@@ -273,7 +273,7 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec
// Try server side copy first - if has optional interface and
// is same underlying remote
actionTaken = "Copied (server side copy)"
- if doCopy := f.Features().Copy; doCopy != nil && SameConfig(src.Fs(), f) {
+ if doCopy := f.Features().Copy; doCopy != nil && (SameConfig(src.Fs(), f) || (SameRemoteType(src.Fs(), f) && f.Features().ServerSideAcrossConfigs)) {
newDst, err = doCopy(src, remote)
if err == nil {
dst = newDst
@@ -392,7 +392,7 @@ func Move(fdst fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Ob
return newDst, nil
}
// See if we have Move available
- if doMove := fdst.Features().Move; doMove != nil && SameConfig(src.Fs(), fdst) {
+ if doMove := fdst.Features().Move; doMove != nil && (SameConfig(src.Fs(), fdst) || (SameRemoteType(src.Fs(), fdst) && fdst.Features().ServerSideAcrossConfigs)) {
// Delete destination if it exists
if dst != nil {
err = DeleteFile(dst)
@@ -525,6 +525,11 @@ func DeleteFiles(toBeDeleted fs.ObjectsChan) error {
return DeleteFilesWithBackupDir(toBeDeleted, nil)
}
+// SameRemoteType returns true if fdst and fsrc are the same type
+func SameRemoteType(fdst, fsrc fs.Info) bool {
+ return fmt.Sprintf("%T", fdst) == fmt.Sprintf("%T", fsrc)
+}
+
// SameConfig returns true if fdst and fsrc are using the same config
// file entry
func SameConfig(fdst, fsrc fs.Info) bool {