LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into fix/guard-new-sidecar
Michael Anderson96ae1dbcb5bc
diff --cc crates/engine/src/tests_export.rsindex c752230e3,d0f174245..f4cd32e3e--- a/crates/engine/src/tests_export.rs+++ b/crates/engine/src/tests_export.rs@@@ -313,26 -313,30 +313,50 @@@ fn curve_preset_export_never_overwritespreset_export_preserves_originals("curve.exportPresets", json!({"names": ["Linear"]}), "curve-export-guard");}+/// A new file named like a photo's sidecar, in the photo's folder, would be read back as that+/// photo's edits: refused even though nothing is there yet.+#[test]+fn preset_export_never_creates_a_photos_sidecar() {+ let (mut s, _, dir, _, _) = library_with_jpeg("preset-export-new-sidecar");+ std::fs::create_dir_all(dir.join("presets")).unwrap();+ for name in ["IMG_1.xmp", "IMG_1.jpg.xmp", "presets/../IMG_1.xmp"] {+ let path = dir.join(name);+ assert!(!path.exists(), "{name} isn't there before the export");+ let error = s.execute("preset.export", &json!({"ids": ["lc.warm-glow"], "path": path.to_string_lossy()})).unwrap_err().to_string();+ assert!(error.contains("XMP sidecar of IMG_1.jpg"), "{error}");+ assert!(!path.exists(), "{name} was not created");+ }+ // the same name in another folder is an ordinary preset file+ let elsewhere = dir.join("presets/IMG_1.xmp");+ s.execute("preset.export", &json!({"ids": ["lc.warm-glow"], "path": elsewhere.to_string_lossy()})).unwrap();+ assert!(elsewhere.exists());+ let _ = std::fs::remove_dir_all(dir);+}++ /// #1944: Export Keywords went straight to `std::fs::write`, replacing a library original.+ #[test]+ fn keyword_export_never_overwrites_originals_or_sidecars() {+ preset_export_preserves_originals("keyword.export", json!({}), "keyword-export-guard");+ }++ #[test]+ fn keyword_export_preserves_the_previous_file_on_write_failure() {+ let dir = temp_dir("keyword-export-failure");+ let mut s = Session::with_demo();+ let path = dir.join("keywords.txt");+ let params = json!({"path": path.to_string_lossy()});+ s.execute("keyword.export", ¶ms).unwrap();+ let previous = std::fs::read(&path).unwrap();+ {+ let _fault = lightcraft_catalog::safe_file::fail_writes_after(4);+ assert!(s.execute("keyword.export", ¶ms).is_err(), "keyword.export must report the failed write");+ }+ assert_eq!(std::fs::read(&path).unwrap(), previous, "the prior export is kept");+ s.execute("keyword.export", ¶ms).unwrap();+ assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 1, "no temporary files remain");+ let _ = std::fs::remove_dir_all(dir);+ }+#[test]fn preset_exports_preserve_previous_files_on_write_failure() {let dir = temp_dir("preset-export-failure");diff --cc docs/whats-new.mdindex 0b7439d42,c27c7e474..d6b787a85--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -31,13 -31,40 +31,45 @@@stay available in All Metadata; PSD edit copies keep their capture date. Original exports with Remove Location Info enabledare refused when a PSD or PSB embeds GPS, since LightCraft cannot strip metadata from a byte-for-byte original copy.+ ### Choose where a Lightroom catalog goes+ - File ▸ Import Lightroom Catalog… now asks first: merge the catalog's photos, collections and edits into the+ library open now, or create a new library for them, named after the catalog and placed next to the open library+ (both can be changed). LightCraft opens the new library, then imports the catalog into it. Cancel does nothing.+ Open Library… on a Lightroom catalog goes through the same choice.+ - To import as before without the question, choose Settings ▸ General ▸ When importing a Lightroom catalog ▸+ Always merge into the open library, or tick Don't ask again in the window. Ask where to import it brings the+ question back.+++ ### Choose which library opens at launch+ - Settings ▸ General ▸ **At launch**: *Open the last library* (as before) or *Ask me*. With *Ask me*, LightCraft+ starts with a window listing your recent libraries: each one's name, the folder it is in and when you last opened+ it. One that is gone (moved, renamed, on a disconnected drive), can't be read or no longer holds a library is+ greyed out with the reason. Each one is checked in the background, showing *Checking…* until it answers (and that+ the drive isn't answering after 5 s), so the list never waits on a network share that is offline or a disk that+ has to wake up; File ▸ Open Recent Library uses the same answers (it greys out only libraries that are gone). Making the list only looks: it never locks or writes anything in your libraries, so one+ that another program has open is reported, with who has it, when you press **Open**, and the window stays. The+ last library is selected; **Open** (or Return, or a double-click) opens it,+ **Open Another…** asks for a folder, **New Library…** makes one, **Quit** (or Esc) quits. ↑ and ↓ move through+ the list.+ - Holding Alt (Option on a Mac) as the window appears shows the same list once, over the library that opened: open+ another one from it, or press Esc to keep working where you were. On a Mac, an Option key held from before+ LightCraft starts is only noticed once it changes, so press it as the window appears.+ - `--library` and `LIGHTCRAFT_LIBRARY` still decide the library when given, and `lightcraft-cli` never asks.+ - File ▸ Open Recent Library ▸ **Remove from List** forgets one library, and the launch window's **Remove from+ List** does the same. Only the entry goes: the library and its photos stay where they are. Agents use+ `app.recentLibraries {remove: path}`; its list now also says when each library was last opened (`lastOpened`).+ - Photos dropped on the window while the list (or the window of a library that couldn't open) is up wait for the+ library you open and are imported into it, as files given on the command line are; presets dropped then are+ refused with a note, since they belong to a library.+## 2026-10-22+### Exports don't create a photo's sidecar+- Saving an export, a preset or any other file as `IMG_1.xmp` or `IMG_1.jpg.xmp` in the folder of the library photo+ `IMG_1.jpg` is now refused when no sidecar is there yet, as writing over an existing one already was. The library+ would have read the new file back as that photo's edits.+### Reliability- Opening a library no longer writes through a link left at the lock's owner note (`catalog.lock.owner`): the linkis removed and a new note made in its place, so the file it pointed to is never changed (as for the catalog's