diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 01e3fd6a4..798db047f 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -299,6 +299,17 @@ a non root folder as its starting point. Default: true, Help: "Send files to the trash instead of deleting permanently.\n\nDefaults to true, namely sending files to the trash.\nUse `--drive-use-trash=false` to delete files permanently instead.", Advanced: true, + }, { + Name: "copy_shortcut_content", + Default: false, + Help: `Server side copy contents of shortcuts instead of the shortcut. + +When doing server side copies, normally rclone will copy shortcuts as +shortcuts. + +If this flag is used then rclone will copy the contents of shortcuts +rather than shortcuts themselves when doing server side copies.`, + Advanced: true, }, { Name: "skip_gdocs", Default: false, @@ -578,6 +589,7 @@ type Options struct { TeamDriveID string `config:"team_drive"` AuthOwnerOnly bool `config:"auth_owner_only"` UseTrash bool `config:"use_trash"` + CopyShortcutContent bool `config:"copy_shortcut_content"` SkipGdocs bool `config:"skip_gdocs"` SkipChecksumGphotos bool `config:"skip_checksum_gphotos"` SharedWithMe bool `config:"shared_with_me"` @@ -2374,9 +2386,16 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, createInfo.Description = "" } - // get the ID of the thing to copy - this is the shortcut if available + // get the ID of the thing to copy + // copy the contents if CopyShortcutContent + // else copy the shortcut only + id := shortcutID(srcObj.id) + if f.opt.CopyShortcutContent { + id = actualID(srcObj.id) + } + var info *drive.File err = f.pacer.Call(func() (bool, error) { info, err = f.svc.Files.Copy(id, createInfo). diff --git a/docs/content/drive.md b/docs/content/drive.md index 23b062dc5..beb17bf9d 100644 --- a/docs/content/drive.md +++ b/docs/content/drive.md @@ -410,7 +410,7 @@ For shortcuts pointing to files: - When downloading the contents of the destination file is downloaded. - When updating shortcut file with a non shortcut file, the shortcut is removed then a new file is uploaded in place of the shortcut. - When server-side moving (renaming) the shortcut is renamed, not the destination file. -- When server-side copying the shortcut is copied, not the contents of the shortcut. +- When server-side copying the shortcut is copied, not the contents of the shortcut. (unless `--drive-copy-shortcut-content` is in use in which case the contents of the shortcut gets copied). - When deleting the shortcut is deleted not the linked file. - When setting the modification time, the modification time of the linked file will be set.