2.2 KiB
2.2 KiB
S006 — Location layer and local backend
Category 03 File browsing · Model: Opus · Effort: medium · Depends on: S001 · Size: M · Human: no Files touched: crates/tunal-core/**
Goal
The protocol-neutral location layer every view talks to, plus the local backend: URIs, entries, errors, the Location trait, a scheme registry and folder watching.
Read
CLAUDE.md §3 (location layer rule), §4; PROMPT.md §Network connections (last bullet).
Steps
- Types:
Uri(scheme, authority, path as bytes;file://paths keepOsString),Entry(raw name + lossy display name, kind incl. symlink target and target kind, size, mtime, mode, uid/gid, hidden),Error(NotFound, PermissionDenied, Exists, NotEmpty, Unsupported, Cancelled, Io, Remote) withneeds_elevation(). Locationtrait (Send + Sync): chunkedlist,stat,open_read,open_write,mkdir,rename,delete,trash,symlink,capabilities(),watch(); unsupported operations default toUnsupported.Locationsregistry: scheme → backend; resolve aUrito its backend.- Local backend:
lstat-based listing (symlinks not followed, target kind resolved), permission-denied folders return an error, non-UTF-8 names intact; watching withnotify(inotify), debounced. - Mime guess by extension (
mime_guess); folders/symlinks typed. - Example
cargo run -p tunal-core --example ls -- <dir>prints entries and timing. - PROGRESS entry, INDEX line, commit
S006: …
End criteria
cargo build --workspace,cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkpass.- On a scratch dir with a non-UTF-8 name, a broken symlink, a
chmod 000folder and 10 000 files,--example lslists everything (the 000 folder reports PermissionDenied) in under 1 s.
Pitfalls
- Never touch the real home in smoke runs: use the scratchpad.
- Keep the trait object-safe; backends for MTP/AFC/SFTP will implement it later.
- No new tests in this plan (D-013): verify with build, clippy and the smoke run; tests come in phase 12.
Handoff (→ PROGRESS.md)
Trait signatures and the URI format (file://, later trash:///, ios://, mtp://, sftp://).