mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 08:58:26 +08:00
box: when doing cleanup delete as much as possible - fixes #5545
Before this change the cleanup routine exited on the first deletion error. This change counts any errors on deletion and exits when the iteration is complete with an error showing the number of deletion failures. Deletion failures will be logged.
This commit is contained in:
parent
308323e9c4
commit
bfecf5301b
|
@ -1095,6 +1095,7 @@ func (f *Fs) deletePermanently(ctx context.Context, itemType, id string) error {
|
|||
|
||||
// CleanUp empties the trash
|
||||
func (f *Fs) CleanUp(ctx context.Context) (err error) {
|
||||
var deleteErrors = 0
|
||||
opts := rest.Opts{
|
||||
Method: "GET",
|
||||
Path: "/folders/trash/items",
|
||||
|
@ -1124,7 +1125,8 @@ func (f *Fs) CleanUp(ctx context.Context) (err error) {
|
|||
if item.Type == api.ItemTypeFolder || item.Type == api.ItemTypeFile {
|
||||
err := f.deletePermanently(ctx, item.Type, item.ID)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to delete file")
|
||||
fs.Errorf(f, "failed to delete trash item %q: %v", item.ID, err)
|
||||
deleteErrors++
|
||||
}
|
||||
} else {
|
||||
fs.Debugf(f, "Ignoring %q - unknown type %q", item.Name, item.Type)
|
||||
|
@ -1136,7 +1138,10 @@ func (f *Fs) CleanUp(ctx context.Context) (err error) {
|
|||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
if deleteErrors != 0 {
|
||||
return errors.Errorf("failed to delete %d trash items", deleteErrors)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DirCacheFlush resets the directory cache - used in testing as an
|
||||
|
|
Loading…
Reference in New Issue
Block a user