MCPcopy
hub / github.com/rclone/rclone / SkipDestructive

Function SkipDestructive

fs/operations/operations.go:2600–2631  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2598// Together they should make sense in this sentence: "Rclone is about
2599// to action subject".
2600func 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
2634func dirName(f fs.Fs, dst fs.Directory, dir string) any {

Callers 15

purgeMethod · 0.92
lifecycleCommandMethod · 0.92
CommandMethod · 0.92
cleanUpBucketMethod · 0.92
deleteVersionMethod · 0.92
cleanUpBucketMethod · 0.92
restoreMethod · 0.92
unTrashMethod · 0.92
TouchFunction · 0.92
renameMethod · 0.92
deleteMethod · 0.92
BasePathFunction · 0.92

Calls 8

GetConfigFunction · 0.92
LogfFunction · 0.92
LogValueFunction · 0.92
SizeSuffixTypeAlias · 0.92
skipDestructiveChooseFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
SizeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…