gravityfile-ops
File operations for gravityfile: copy, move, rename, create, delete, undo and archives.
This crate exists for the grav binary and its sibling crates. Its API
follows their needs and can change in any minor release.
Long-running operations run on blocking threads and report through a
channel: best-effort OperationProgress snapshots, interactive
ConflictRequests, and one reliable completion message. Dropping the
receiver cancels the operation.
Safety model
- New content is assembled in a private staging directory beside its destination and published with a single no-clobber rename, so a failed or cancelled operation never leaves a partial item at a visible path and never silently replaces anything.
- Overwrites the user approves move the replaced item to the system Trash (or delete it permanently, if configured) only after the replacement is complete.
- Copies skip entries they cannot read and report each one instead of discarding everything that did copy; cross-filesystem moves keep the source unless every entry arrived.
- Completed operations return what an undo needs as an
UndoEntry.execute_undomoves and renames items back, sends copies to the Trash, and removes created files and directories only while they are still empty.
use ;
let dir = tempdir?;
let source = dir.path.join;
let backup = dir.path.join;
write?;
create_dir?;
let runtime = new?;
let complete = runtime.block_on;
let complete = complete.expect;
assert_eq!;
assert_eq!;
# Ok::
Licence
MIT or Apache-2.0, at your option.