MCPcopy
hub / github.com/rclone/rclone / CleanUp

Method CleanUp

backend/mega/mega.go:473–499  ·  view source on GitHub ↗

CleanUp deletes all files currently in trash

(ctx context.Context)

Source from the content-addressed store, hash-verified

471
472// CleanUp deletes all files currently in trash
473func (f *Fs) CleanUp(ctx context.Context) (err error) {
474 trash := f.srv.FS.GetTrash()
475 items := []*mega.Node{}
476 _, err = f.list(ctx, trash, func(item *mega.Node) bool {
477 items = append(items, item)
478 return false
479 })
480 if err != nil {
481 return fmt.Errorf("CleanUp failed to list items in trash: %w", err)
482 }
483 fs.Infof(f, "Deleting %d items from the trash", len(items))
484 errors := 0
485 // similar to f.deleteNode(trash) but with HardDelete as true
486 for _, item := range items {
487 fs.Debugf(f, "Deleting trash %q", f.opt.Enc.ToStandardName(item.GetName()))
488 deleteErr := f.pacer.Call(func() (bool, error) {
489 err := f.srv.Delete(item, true)
490 return shouldRetry(ctx, err)
491 })
492 if deleteErr != nil {
493 err = deleteErr
494 errors++
495 }
496 }
497 fs.Infof(f, "Deleted %d items from the trash with %d errors", len(items), errors)
498 return err
499}
500
501// Return an Object from a path
502//

Callers

nothing calls this directly

Calls 9

listMethod · 0.95
InfofFunction · 0.92
DebugfFunction · 0.92
shouldRetryFunction · 0.70
ToStandardNameMethod · 0.65
DeleteMethod · 0.65
ErrorfMethod · 0.45
GetNameMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected