Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge branch 'fix/issue-97-folder-undo' into integrate/safety

Brandon Thomas50cd8dc6dc04
diff --cc crates/engine/src/lib.rs
index 2d68329f5,347739291..bb4760ada
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@@ -382,22 -408,33 +412,40 @@@ impl Session
Ok(e.label)
}
- /// Apply an undo/redo op, first moving the files its renames imply (all or nothing). Files
- /// that can't be moved back after a failure are reported and the library follows them (a
- /// logged change outside the undo history), so none goes missing.
- fn apply_with_files(&mut self, op: &Op) -> Result<Op> {
+ /// Apply an undo/redo op, first renaming the step's folder and moving the files its renames
- /// imply (all or nothing).
++ /// imply (all or nothing). Files that can't be moved back after a failure are reported and the
++ /// library follows them (a logged change outside the undo history), so none goes missing; the
++ /// folder is only moved back when no file was left behind at its new path.
+ fn apply_with_files(&mut self, op: &Op, folder: Option<&FolderMove>) -> Result<Op> {
+ let fs = rename::RealFs;
+ if let Some(f) = folder {
+ cmd::browse::rename_folder_on_disk(&f.from, &f.to).map_err(|e| EngineError::Other(format!("can't move the folder back: {e}")))?;
+ }
+ let undo_folder = || {
+ if let Some(f) = folder {
+ let _ = cmd::browse::rename_folder_on_disk(&f.to, &f.from);
+ }
+ };
let moves = self.file_moves(op);
- if let Err(e) = Session::move_files(&moves) {
- undo_folder();
- return Err(e);
+ if let Err(e) = rename::move_all(&fs, &moves) {
++ if e.stuck.is_empty() {
++ undo_folder();
++ }
+ return Err(EngineError::Other(format!("can't move the files back: {}", self.follow_stuck(op, e, false))));
}
match self.catalog.apply(op.clone()) {
- Ok(inv) => Ok(inv),
+ Ok(inv) => {
+ if let Some(f) = folder {
+ cmd::browse::follow_folder(self, &f.from, &f.to);
+ }
+ Ok(inv)
+ }
Err(e) => {
let back: Vec<(String, String)> = moves.iter().rev().map(|(a, b)| (b.clone(), a.clone())).collect();
- let _ = Session::move_files(&back);
+ if let Err(be) = rename::move_all(&fs, &back) {
+ return Err(EngineError::Other(format!("{e}; the files could not all be moved back: {}", be.message)));
+ }
+ undo_folder();
Err(e.into())
}
}
diff --cc docs/parity.md
index 231b24002,c0cf82aa0..ac62ea34c
--- a/docs/parity.md
+++ b/docs/parity.md
@@@ -713,8 -713,7 +713,8 @@@ From `08-lightroom-classic-extras.md` (
| LRC-LIB-SURVEY | Survey view | P2 | ✅ | `cmd:view.survey` | N |
| LRC-LIB-REFVIEW | Reference view | P2 | ✅ | `cmd:view.reference`, `cmd:photo.setReference`, `crates/ui-egui/src/panels/compare.rs` (`show_reference`) | View ▸ Reference View (⇧R): the reference photo beside the active one (edited with the Edit panel); photo menu ▸ Set as Reference Photo |
| LRC-LIB-CATALOG-PANEL | Catalog sets | P1 | ✅ | `cmd:library.source` (`missing`) | all, recently added, picks, recently deleted, missing photos (when any) |
+| LRC-LIB-CATALOG-LOCK | Catalog open in one program at a time | P1 | ✅ | `cmd:app.openLibrary`, `crates/catalog/src/lock.rs`, `crates/engine/src/library.rs` (`open_library`) | exclusive OS lock on `catalog.lock` for the session (app and `lightcraft-cli --library`); a second opener is refused with who has it (`catalog.lock.owner`: program, process, computer); released by the OS on a crash, so never stale; file systems without locks open unprotected with a warning; no read-only mode; the browser build (OPFS) has no guard across tabs yet. A library that can't be opened at launch (locked, unreadable, newer format, drive missing) shows a window — Try Again, Choose Another Library…, Continue Without Saving (then a banner; nothing written), Quit — instead of a silent demo session (`crates/ui-egui/src/panels/library_problem.rs`) |
- | LRC-LIB-FOLDERS | Disk folder tree | P1 | ✅ | `cmd:library.browse`, `cmd:folder.rename`, `cmd:folder.move`, `crates/ui-egui/src/panels/left.rs` (`local_section`, `folder_tree`) | standard places + the browsed folder + Browse Folder…, each an expandable tree of subfolders, breadcrumb navigation; context menu: Rename Folder…, Move Folder To…, Show in Finder (on disk, photos relinked; like the file manager, not an undo step) |
+ | LRC-LIB-FOLDERS | Disk folder tree | P1 | ✅ | `cmd:library.browse`, `cmd:folder.rename`, `cmd:folder.move`, `crates/ui-egui/src/panels/left.rs` (`local_section`, `folder_tree`) | standard places + the browsed folder + Browse Folder…, each an expandable tree of subfolders, breadcrumb navigation; context menu: Rename Folder…, Move Folder To…, Show in Finder (on disk, photos relinked; one undo step each: undo / redo move the folder back and forth, refused when the destination is taken) |
| LRC-LIB-COLLECTIONS | Collections & sets | P1 | ✅ | `cmd:album.create`, `cmd:album.createSmart`, `cmd:album.toggleTarget`, `cmd:album.setTarget`, `cmd:album.clearQuick` | albums + folders (sets), smart albums (rule editor), Quick Collection and target album (B in the grids adds / removes the selection; album menu ▸ Set as Target Album; the target is marked +) |
| LRC-LIB-SMARTCOLL | Smart-collection rules | P1 | ✅ | `cmd:album.createSmart`, `cmd:album.setRules`, `cmd:album.ruleFields`, `cmd:dialog.smartAlbum`, `crates/catalog/src/rules.rs`, `crates/ui-egui/src/panels/rules_editor.rs` | rule editor: match all / any / none, nested groups (⌥+ or + Group), 26 fields (rating, flag, label, type, edits, keywords, any text, filename, format, title, caption, camera, lens, location, creator, copyright, copyright status, capture / import / edit date, ISO, aperture, focal length, megapixels, GPS, virtual copy, album) with text / number / date / in-the-last operators; live match count; also usable as a library filter (`ruleSet`) |
| LRC-LIB-PUBLISH | Publish services | P2 | ⬜ | | |
diff --cc docs/whats-new.md
index dc7012dc3,1d825a5bd..ce7cd6c1b
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -51,23 -19,11 +51,26 @@@
in short pieces so slow integrated GPUs aren't reset by their watchdog. `ui.inspect` → `perf`
(`gpuReason`, `gpuFallback`), Help ▸ System Info and Settings ▸ Performance say why the GPU isn't
used (e.g. a skipped software adapter such as llvmpipe) and why the last render fell back.
+- The thumbnail cache only ever counts and deletes its own files (issue #98): a library opened on a folder that
+ already has a `thumbs/` folder of other pictures no longer loses them when the cache is trimmed or cleared.
+- Settings files are never quietly reset (issue #103): a damaged `prefs.json`, `presets.json` or `view.json` is kept
+ as `<name>.corrupt-<time>` and you're told; one that can't be read (e.g. locked by another program) is left alone
+ for the session instead of being overwritten with defaults. The app settings (`ui.json`, which remembers your
+ library) are written atomically and saved as soon as you open another library, not only at quit. Quitting while
+ changes couldn't be saved tries once more, then asks: Try Saving Again, Quit Anyway or Cancel.
### Library
+- Rename Photos never overwrites another photo when only the letter case changes (issue #95): on case-sensitive
+ volumes (Linux, case-sensitive APFS) `img_1.JPG` next to `IMG_1.JPG` is a different photo and the renamed one gets
+ `img_1-1.JPG`; on case-insensitive volumes the case change still goes through.
+- Rename Photos reports files it could not move back after a failure (issue #105), e.g. when a network share drops
+ mid-batch: the error lists them (old → new) and the library points at their new names (an undoable partial rename),
+ so none shows as missing. Renaming one of a raw + JPEG pair copies their shared `IMG_0001.xmp` instead of taking
+ it away from the other (issue #92). Find Missing Photos also finds renamed files by their content, prefers a content match
+ over a same-name same-size look-alike, and skips (and reports) photos it can't tell apart instead of guessing.
+ - Rename Folder… and Move Folder To… (Local) can be undone and redone (issue #97): the folder moves back on disk with
+ its photos and XMP sidecars, and the photos point at it again. If something now occupies the old place, the undo
+ is refused and nothing is overwritten.
- Smart albums with a rule editor: match all / any / none, nested groups, 26 fields.
- Quick Collection and target album (B in the grid), keyword sets (⌥1–⌥9), colour-label sets.
- Colour-label filter with several labels at once; expandable folder tree in Local.