diff --git a/pkg/storage/fs/posix/trashbin/trashbin.go b/pkg/storage/fs/posix/trashbin/trashbin.go index 7e93b6dd63..d8336605d5 100644 --- a/pkg/storage/fs/posix/trashbin/trashbin.go +++ b/pkg/storage/fs/posix/trashbin/trashbin.go @@ -100,7 +100,7 @@ func trashRootForNode(n *node.Node) string { return filepath.Join(n.SpaceRoot.InternalPath(), ".Trash") } -func (tb *Trashbin) MoveToTrash(n *node.Node, path string) error { +func (tb *Trashbin) MoveToTrash(ctx context.Context, n *node.Node, path string) error { key := uuid.New().String() trashPath := trashRootForNode(n) @@ -120,6 +120,18 @@ func (tb *Trashbin) MoveToTrash(n *node.Node, path string) error { return err } + // purge metadata + if err = tb.lu.IDCache.DeleteByPath(ctx, path); err != nil { + return err + } + if err != nil { + return err + } + err = tb.lu.MetadataBackend().Rename(path, trashPath) + if err != nil { + return err + } + return os.Rename(path, filepath.Join(trashPath, "files", key+".trashitem")) }