Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.37 KB

File metadata and controls

37 lines (29 loc) · 1.37 KB

Trash

PlainNAS has two trash flows:

PlainNAS has a single unified trash for both Files and Media.

Unified Trash

  • Location: per-disk ${MOUNT}/.nas-trash (one trash directory per filesystem / physical disk)
  • Used by: Files view and Media (Images/Videos/Audios)
  • Implementation (core rules):
    • Delete is always a single rename(2) (O(1))
    • Never traverses directories; never touches children
    • Never performs cross-filesystem copy
    • Trash contents are bucketed by date only for performance/GC (business logic must not depend on it)
    • Restore/GC logic uses Pebble metadata as the single source of truth
  • Directory layout (per disk):
${MOUNT}/.nas-trash/
	data/YYYY/MM/f_<id>
	data/YYYY/MM/d_<id>
	.lock
  • Metadata storage:

    • Stored in the existing default Pebble DB (db.GetDefault()) under the trash:* key namespace
    • No sidecar .metadata files are required for correctness
  • Code:

    • Files trash implementation: internal/fs/trash.go
    • Media actions call into the same implementation (no separate media trash directory)

Notes:

  • ${DATA_DIR} defaults to /var/lib/plainnas (see internal/consts/consts.go).
  • .nas-trash is a hidden directory and is excluded from indexing/scans.
  • Mountpoint detection uses /proc/self/mountinfo and falls back to resolving symlinked path components when needed (e.g. if a mount is accessed via a symlink like /DATA).