Tunal/Plans/03 File browsing/S007-file-ops-engine.md
astar76 c51e63a4a9 S007: file operations engine, freedesktop trash and trash:/// backend
Jobs with progress, cancel, conflict and error requests; scan pass,
copy_file_range and stream copies, rename moves; per-filesystem trash
with .trashinfo, restore and empty; ops smoke example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:04:31 -06:00

2.2 KiB

S007 — File operations engine and trash

Category 03 File browsing · Model: Opus · Effort: medium · Depends on: S006 · Size: L · Human: no Files touched: crates/tunal-core/src/ops/**, crates/tunal-core/src/trash.rs

Goal

Background jobs for copy, move, delete, trash, restore, empty trash, mkdir, rename and link across any backends: progress, cancel, conflicts, partial failures, and freedesktop trash with a trash:/// location.

Read

CLAUDE.md §4 (file ops, trash); crates/tunal-core/src/lib.rs and the trait from S006.

Steps

  • Job model: kinds, JobHandle with progress (bytes/files/current name), cancel flag, conflict requests (Skip/Overwrite/Rename/auto-rename + apply to all), error requests (Retry/Skip/Abort; PermissionDenied flagged for elevation).
  • Scan pass for totals; worker queue; copy through open_read/open_write streams (cross-backend), local fast paths (rename for same-filesystem move, copy_file_range); move across devices = copy + delete; keep mtime/mode where supported.
  • Auto-rename naming name (2).ext; never copy a folder into itself.
  • Trash per the freedesktop spec: $XDG_DATA_HOME/Trash and $topdir/.Trash-$uid (mounts from /proc/self/mountinfo), .trashinfo with encoded path and DeletionDate, collision-free names.
  • trash:/// backend: list (original path, date), restore (with conflict), delete permanently, empty.
  • Example --example ops runs a copy with a conflict and a trash/restore round trip in the scratchpad (with XDG_DATA_HOME pointed there).
  • PROGRESS entry, INDEX line, commit S007: …

End criteria

  • cargo build --workspace, cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check pass.
  • --example ops output shows progress, a resolved conflict, and a file trashed and restored, all inside the scratchpad.

Pitfalls

  • Tests and smoke runs never use the real trash: override XDG_DATA_HOME.
  • Partial failures must not stop the rest of the job; collect them for the UI.
  • No new tests in this plan (D-013): verify with build, clippy and the smoke run; tests come in phase 12.

Handoff (→ PROGRESS.md)

Job API, progress/conflict message types, trash URI format.