PlainNAS has two trash flows:
PlainNAS has a single unified trash for both Files and Media.
- 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
- Delete is always a single
- 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 thetrash:*key namespace - No sidecar
.metadatafiles are required for correctness
- Stored in the existing default Pebble DB (
-
Code:
- Files trash implementation:
internal/fs/trash.go - Media actions call into the same implementation (no separate media trash directory)
- Files trash implementation:
Notes:
${DATA_DIR}defaults to/var/lib/plainnas(seeinternal/consts/consts.go)..nas-trashis a hidden directory and is excluded from indexing/scans.- Mountpoint detection uses
/proc/self/mountinfoand falls back to resolving symlinked path components when needed (e.g. if a mount is accessed via a symlink like/DATA).