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

drive: fix move and copy from TeamDrive to GDrive

Fionera2657d705677a
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index 49e43c9a7..91781171c 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -1877,11 +1877,16 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
return nil, err
}
+ supportTeamDrives, err := f.ShouldSupportTeamDrives(src)
+ if err != nil {
+ return nil, err
+ }
+
var info *drive.File
err = f.pacer.Call(func() (bool, error) {
info, err = f.svc.Files.Copy(srcObj.id, createInfo).
Fields(partialFields).
- SupportsTeamDrives(f.isTeamDrive).
+ SupportsTeamDrives(supportTeamDrives).
KeepRevisionForever(f.opt.KeepRevisionForever).
Do()
return shouldRetry(err)
@@ -2025,6 +2030,11 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
dstParents := strings.Join(dstInfo.Parents, ",")
dstInfo.Parents = nil
+ supportTeamDrives, err := f.ShouldSupportTeamDrives(src)
+ if err != nil {
+ return nil, err
+ }
+
// Do the move
var info *drive.File
err = f.pacer.Call(func() (bool, error) {
@@ -2032,7 +2042,7 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
RemoveParents(srcParentID).
AddParents(dstParents).
Fields(partialFields).
- SupportsTeamDrives(f.isTeamDrive).
+ SupportsTeamDrives(supportTeamDrives).
Do()
return shouldRetry(err)
})
@@ -2043,6 +2053,20 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
return f.newObjectWithInfo(remote, info)
}
+// ShouldSupportTeamDrives returns the request should support TeamDrives
+func (f *Fs) ShouldSupportTeamDrives(src fs.Object) (bool, error) {
+ srcIsTeamDrive := false
+ if srcFs, ok := src.Fs().(*Fs); ok {
+ srcIsTeamDrive = srcFs.isTeamDrive
+ }
+
+ if f.isTeamDrive {
+ return true, nil
+ }
+
+ return srcIsTeamDrive, nil
+}
+
// PublicLink adds a "readable by anyone with link" permission on the given file or folder.
func (f *Fs) PublicLink(remote string) (link string, err error) {
id, err := f.dirCache.FindDir(remote, false)