drive: add --drive-skip-dangling-shortcuts flag - fixes #5949

This flag enables dangling shortcuts to be skipped without an error.
This commit is contained in:
Nick Craig-Wood 2022-01-28 17:01:43 +00:00
parent dc7e3ea1e3
commit d3a1001094

View File

@ -553,6 +553,14 @@ Google don't document so it may break in the future.
Normally rclone dereferences shortcut files making them appear as if Normally rclone dereferences shortcut files making them appear as if
they are the original file (see [the shortcuts section](#shortcuts)). they are the original file (see [the shortcuts section](#shortcuts)).
If this flag is set then rclone will ignore shortcut files completely. If this flag is set then rclone will ignore shortcut files completely.
`,
Advanced: true,
Default: false,
}, {
Name: "skip_dangling_shortcuts",
Help: `If set skip dangling shortcut files.
If this is set then rclone will not show any dangling shortcuts in listings.
`, `,
Advanced: true, Advanced: true,
Default: false, Default: false,
@ -616,6 +624,7 @@ type Options struct {
StopOnUploadLimit bool `config:"stop_on_upload_limit"` StopOnUploadLimit bool `config:"stop_on_upload_limit"`
StopOnDownloadLimit bool `config:"stop_on_download_limit"` StopOnDownloadLimit bool `config:"stop_on_download_limit"`
SkipShortcuts bool `config:"skip_shortcuts"` SkipShortcuts bool `config:"skip_shortcuts"`
SkipDanglingShortcuts bool `config:"skip_dangling_shortcuts"`
Enc encoder.MultiEncoder `config:"encoding"` Enc encoder.MultiEncoder `config:"encoding"`
} }
@ -918,6 +927,11 @@ OUTER:
if err != nil { if err != nil {
return false, fmt.Errorf("list: %w", err) return false, fmt.Errorf("list: %w", err)
} }
// leave the dangling shortcut out of the listings
// we've already logged about the dangling shortcut in resolveShortcut
if f.opt.SkipDanglingShortcuts && item.MimeType == shortcutMimeTypeDangling {
continue
}
} }
// Check the case of items is correct since // Check the case of items is correct since
// the `=` operator is case insensitive. // the `=` operator is case insensitive.