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]>
2.2 KiB
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,
JobHandlewith 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_writestreams (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/Trashand$topdir/.Trash-$uid(mounts from/proc/self/mountinfo),.trashinfowith encoded path and DeletionDate, collision-free names. trash:///backend: list (original path, date), restore (with conflict), delete permanently, empty.- Example
--example opsruns a copy with a conflict and a trash/restore round trip in the scratchpad (withXDG_DATA_HOMEpointed there). - PROGRESS entry, INDEX line, commit
S007: …
End criteria
cargo build --workspace,cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkpass.--example opsoutput 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.