mirror of
https://github.com/rclone/rclone.git
synced 2025-01-11 08:49:37 +01:00
Add ServerSideAcrossConfig Flag and check for it. fixes #2728
This commit is contained in:
parent
118a8b949e
commit
55b9a4ed30
@ -907,6 +907,7 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) {
|
|||||||
ReadMimeType: true,
|
ReadMimeType: true,
|
||||||
WriteMimeType: true,
|
WriteMimeType: true,
|
||||||
CanHaveEmptyDirectories: true,
|
CanHaveEmptyDirectories: true,
|
||||||
|
ServerSideAcrossConfigs: true,
|
||||||
}).Fill(f)
|
}).Fill(f)
|
||||||
|
|
||||||
// Create a new authorized Drive client.
|
// Create a new authorized Drive client.
|
||||||
|
1
fs/fs.go
1
fs/fs.go
@ -409,6 +409,7 @@ type Features struct {
|
|||||||
BucketBased bool // is bucket based (like s3, swift etc)
|
BucketBased bool // is bucket based (like s3, swift etc)
|
||||||
SetTier bool // allows set tier functionality on objects
|
SetTier bool // allows set tier functionality on objects
|
||||||
GetTier bool // allows to retrieve storage tier of 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
|
// Purge all files in the root and the root directory
|
||||||
//
|
//
|
||||||
|
@ -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
|
// Try server side copy first - if has optional interface and
|
||||||
// is same underlying remote
|
// is same underlying remote
|
||||||
actionTaken = "Copied (server side copy)"
|
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)
|
newDst, err = doCopy(src, remote)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dst = newDst
|
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
|
return newDst, nil
|
||||||
}
|
}
|
||||||
// See if we have Move available
|
// 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
|
// Delete destination if it exists
|
||||||
if dst != nil {
|
if dst != nil {
|
||||||
err = DeleteFile(dst)
|
err = DeleteFile(dst)
|
||||||
@ -525,6 +525,11 @@ func DeleteFiles(toBeDeleted fs.ObjectsChan) error {
|
|||||||
return DeleteFilesWithBackupDir(toBeDeleted, nil)
|
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
|
// SameConfig returns true if fdst and fsrc are using the same config
|
||||||
// file entry
|
// file entry
|
||||||
func SameConfig(fdst, fsrc fs.Info) bool {
|
func SameConfig(fdst, fsrc fs.Info) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user