Skip to content

Commit

Permalink
clean empty trash node path on delete
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed May 28, 2024
1 parent 5687911 commit 2a141d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/clean-trash-node-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: clean empty trash node path on delete

We now delete empty directories in the trash when an item is purged or restored. This prevents old empty directories from slowing down the globbing of trash items.

https://github.com/cs3org/reva/pull/4700
12 changes: 8 additions & 4 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,13 @@ func (t *Tree) RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPa
return errors.Wrap(err, "Decomposedfs: could not resolve trash root")
}
deletePath = filepath.Join(resolvedTrashRoot, trashPath)
}
if err = os.Remove(deletePath); err != nil {
logger.Error().Err(err).Str("trashItem", trashItem).Msg("error deleting trash item")
if err = os.Remove(deletePath); err != nil {
logger.Error().Err(err).Str("trashItem", trashItem).Str("deletePath", deletePath).Str("trashPath", trashPath).Msg("error deleting trash item")
}
} else {
if err = utils.RemoveItem(deletePath); err != nil {
logger.Error().Err(err).Str("trashItem", trashItem).Str("deletePath", deletePath).Str("trashPath", trashPath).Msg("error recursively deleting trash item")
}
}

var sizeDiff int64
Expand Down Expand Up @@ -651,7 +655,7 @@ func (t *Tree) PurgeRecycleItemFunc(ctx context.Context, spaceid, key string, pa
}
deletePath = filepath.Join(resolvedTrashRoot, path)
}
if err = os.Remove(deletePath); err != nil {
if err = utils.RemoveItem(deletePath); err != nil {
logger.Error().Err(err).Str("deletePath", deletePath).Msg("error deleting trash item")
return err
}
Expand Down

0 comments on commit 2a141d9

Please sign in to comment.