Skip to content

Commit a054a79

Browse files
abhiraj2NyaMisty
authored andcommitted
drive: added --drive-copy-shortcut-content - fixes #4604
1 parent e274ea0 commit a054a79

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

backend/drive/drive.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ a non root folder as its starting point.
331331
Default: true,
332332
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.",
333333
Advanced: true,
334+
}, {
335+
Name: "copy_shortcut_content",
336+
Default: false,
337+
Help: `Server side copy contents of shortcuts instead of the shortcut.
338+
339+
When doing server side copies, normally rclone will copy shortcuts as
340+
shortcuts.
341+
342+
If this flag is used then rclone will copy the contents of shortcuts
343+
rather than shortcuts themselves when doing server side copies.`,
344+
Advanced: true,
334345
}, {
335346
Name: "skip_gdocs",
336347
Default: false,
@@ -614,6 +625,7 @@ type Options struct {
614625
TeamDriveID string `config:"team_drive"`
615626
AuthOwnerOnly bool `config:"auth_owner_only"`
616627
UseTrash bool `config:"use_trash"`
628+
CopyShortcutContent bool `config:"copy_shortcut_content"`
617629
SkipGdocs bool `config:"skip_gdocs"`
618630
SkipChecksumGphotos bool `config:"skip_checksum_gphotos"`
619631
SharedWithMe bool `config:"shared_with_me"`
@@ -2893,9 +2905,16 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
28932905
createInfo.Description = ""
28942906
}
28952907

2896-
// get the ID of the thing to copy - this is the shortcut if available
2908+
// get the ID of the thing to copy
2909+
// copy the contents if CopyShortcutContent
2910+
// else copy the shortcut only
2911+
28972912
id := shortcutID(srcObj.id)
28982913

2914+
if f.opt.CopyShortcutContent {
2915+
id = actualID(srcObj.id)
2916+
}
2917+
28992918
var info *drive.File
29002919
err = f.pacer.Call(func() (bool, error) {
29012920
// Mod

docs/content/drive.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ For shortcuts pointing to files:
410410
- When downloading the contents of the destination file is downloaded.
411411
- When updating shortcut file with a non shortcut file, the shortcut is removed then a new file is uploaded in place of the shortcut.
412412
- When server-side moving (renaming) the shortcut is renamed, not the destination file.
413-
- When server-side copying the shortcut is copied, not the contents of the shortcut.
413+
- 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).
414414
- When deleting the shortcut is deleted not the linked file.
415415
- When setting the modification time, the modification time of the linked file will be set.
416416

0 commit comments

Comments
 (0)