Skip to content

Commit

Permalink
Do not destroy metadata when moving items into the trashbin
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Aug 22, 2024
1 parent 32a9971 commit c706498
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/storage/fs/posix/trashbin/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"))
}

Expand Down

0 comments on commit c706498

Please sign in to comment.