Skip to content

Commit

Permalink
drive: added --drive-copy-shortcut-content - fixes #4604
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiraj2 authored and NyaMisty committed Feb 5, 2022
1 parent e274ea0 commit a054a79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion backend/drive/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,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,
Expand Down Expand Up @@ -614,6 +625,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"`
Expand Down Expand Up @@ -2893,9 +2905,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) {
// Mod
Expand Down
2 changes: 1 addition & 1 deletion docs/content/drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit a054a79

Please sign in to comment.