Skip to content

Trash & recovery

What happens to deleted files — understanding trash, restoring deleted items, and restoring revisions.

Deleting a file or directory moves that inode to the trash. Deleting a non-empty directory without using the “recursive” option will raise an error. Files and directories can be restored from within the trash on demand.

Items in the trash can be enumerated using the List trash API or loonfs trash. Each entry includes inode_id (such as ino_42), inode_kind, deletion_seq, deleted_by, and deleted_at_ms. The required deleted_binding names the parent inode and display name the deletion removed.

Items can be recovered with restore_deleted. Both inode_id and deletion_seq are required so a stale request cannot undo a later deletion of the same inode. By default, the restore puts the item back under the same parent inode and display name it had before deletion. Because the recovery record keeps the parent identity rather than an old path string, this still works when an ancestor was renamed.

Commands
loonfs restore --inode ino_42 --deletion-seq 417

See the restore_deleted request schema in the Apply a commit API docs for details.

An entry remains recoverable while its deletion_seq is above the namespace’s retention_floor_seq. Once the floor reaches the deletion, the entry expires, disappears from the trash, and a restore returns not_deleted. Compaction and garbage collection can then reclaim its metadata and unreferenced content. See Data lifecycle.

A successful restore creates a new path binding and therefore a new binding_version.

Files can be deleted (sent to the trash), and replaced with newer revisions. The operations to recover the previous state are different:

  • To recover a deleted file → restore_deleted (this page).
  • To recover an earlier version of an existing file → restore_revision, see Revisions.