CleanUp deletes all files currently in trash
(ctx context.Context)
| 471 | |
| 472 | // CleanUp deletes all files currently in trash |
| 473 | func (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 | // |
nothing calls this directly
no test coverage detected