SkipDestructive should be called whenever rclone is about to do an destructive operation. It will check the --dry-run flag and it will ask the user if the --interactive flag is set. subject should be the object or directory in use action should be a descriptive word or short phrase Together they
(ctx context.Context, subject any, action string)
| 2598 | // Together they should make sense in this sentence: "Rclone is about |
| 2599 | // to action subject". |
| 2600 | func SkipDestructive(ctx context.Context, subject any, action string) (skip bool) { |
| 2601 | var flag string |
| 2602 | ci := fs.GetConfig(ctx) |
| 2603 | switch { |
| 2604 | case ci.DryRun: |
| 2605 | flag = "--dry-run" |
| 2606 | skip = true |
| 2607 | case ci.Interactive: |
| 2608 | flag = "--interactive" |
| 2609 | interactiveMu.Lock() |
| 2610 | defer interactiveMu.Unlock() |
| 2611 | var found bool |
| 2612 | skip, found = skipped[action] |
| 2613 | if !found { |
| 2614 | skip = skipDestructiveChoose(ctx, subject, action) |
| 2615 | } |
| 2616 | default: |
| 2617 | return false |
| 2618 | } |
| 2619 | if skip { |
| 2620 | size := int64(-1) |
| 2621 | if do, ok := subject.(interface{ Size() int64 }); ok { |
| 2622 | size = do.Size() |
| 2623 | } |
| 2624 | if size >= 0 { |
| 2625 | fs.Logf(subject, "Skipped %s as %s is set (size %v)", fs.LogValue("skipped", action), flag, fs.LogValue("size", fs.SizeSuffix(size))) |
| 2626 | } else { |
| 2627 | fs.Logf(subject, "Skipped %s as %s is set", fs.LogValue("skipped", action), flag) |
| 2628 | } |
| 2629 | } |
| 2630 | return skip |
| 2631 | } |
| 2632 | |
| 2633 | // Return the best way of describing the directory for the logs |
| 2634 | func dirName(f fs.Fs, dst fs.Directory, dir string) any { |
no test coverage detected
searching dependent graphs…