Skip to content

Commit 5ff2b7d

Browse files
emmertexclaude
andcommitted
Upstream review r3: grid Shift+Up/Down, library date-folder rename, small fixes
Ports upstream #2998 (Shift+Up/Down and Ctrl+Shift+arrows extend the grid selection), #3016 (a date folder inside the library can be renamed), #3024 (face scan progress starts over in another library), #3013 (built-in lens profiles: no-make cameras, overflowing focal ranges), #3012 (estimated CA keeps the crop inside every plane), #3020 (Windows hard links count as the original), #3010 (file:// mirror escapes), #3009/#435 (merge reports reused) and #3035 (Italian strings Chromaforge has). Sources: upstream storytold/lightcraft PRs above (ported). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent be53dd1 commit 5ff2b7d

25 files changed

Lines changed: 321 additions & 23 deletions

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ getrandom = "0.3"
9292
# All date/time conversion goes through chrono (no hand-rolled calendar code beyond the 400-year range extension; CLAUDE.md).
9393
chrono = { version = "0.4.45", default-features = false, features = ["std"] }
9494
rayon = "1"
95+
same-file = "1" # lcc-catalog reads a file's volume serial number and file index with it on Windows
9596
proptest = "1"
9697
bytemuck = { version = "1", features = ["derive"] }
9798
half = { version = "2", default-features = false } # f32 → f16 for the HDR loupe texture

‎crates/catalog/Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ siphasher = { workspace = true }
2929
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3030
redb = { workspace = true }
3131

32+
[target.'cfg(windows)'.dependencies]
33+
same-file = { workspace = true }
34+
3235
[dev-dependencies]
3336
lcc-fuzzkit = { workspace = true }
3437
lcc-geom = { workspace = true }

‎crates/catalog/src/safe_file.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//! replacing anything** (a hard link, which fails on a taken name; where the volume has no hard
2424
//! links, an exclusive create that claims the name, then a rename over that placeholder).
2525
//! - [`same_file`] tells whether two paths name the same file on disk (device + inode on Unix,
26+
//! volume serial number + file index on Windows,
2627
//! resolved paths elsewhere), for "is this target an original?" checks.
2728
//! - [`open_regular`] / [`open_or_create_regular`] open a library file in place (to read, append
2829
//! or cut it), never through a link planted at its name, nor a FIFO or a device (issue #2552).
@@ -389,6 +390,14 @@ pub fn same_file(a: &Path, b: &Path) -> bool {
389390
}
390391
#[cfg(not(unix))]
391392
{
393+
// A hard link has its own path but shares the volume serial number and file index with
394+
// its original. A volume that does not report them is compared by resolved path below.
395+
#[cfg(windows)]
396+
{
397+
if ::same_file::is_same_file(a, b).unwrap_or(false) {
398+
return true;
399+
}
400+
}
392401
if ma.len() != mb.len() {
393402
return false;
394403
}
@@ -611,6 +620,20 @@ mod tests {
611620
let _ = fs::remove_dir_all(&d);
612621
}
613622

623+
#[test]
624+
fn same_file_sees_a_hard_link_under_another_name() {
625+
let d = temp("same-link");
626+
let p = d.join("IMG_1.jpg");
627+
fs::write(&p, b"original").unwrap();
628+
let linked = d.join("linked.png");
629+
fs::hard_link(&p, &linked).unwrap();
630+
fs::write(d.join("copy.png"), b"original").unwrap();
631+
assert!(same_file(&p, &linked), "a hard link is the same file");
632+
assert!(same_file(&linked, &p));
633+
assert!(!same_file(&p, &d.join("copy.png")), "a copy with the same content and length is another file");
634+
let _ = fs::remove_dir_all(&d);
635+
}
636+
614637
#[test]
615638
fn same_file_sees_through_other_spellings() {
616639
let d = temp("same");

‎crates/engine/src/cmd/browse.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,13 @@ pub(crate) fn move_folder(s: &mut Session, from: &str, to: &str) -> std::result:
539539
if !src.is_dir() {
540540
return Err(format!("{from} is not a folder"));
541541
}
542-
if s.library.as_ref().is_some_and(|l| l.dir.starts_with(src) || src == l.dir) {
542+
// `a/../b` names a folder without spelling it, which the checks below and the relink can't see
543+
if src.components().any(|c| matches!(c, std::path::Component::ParentDir)) {
544+
return Err(format!("{from}: give the folder's path without '..'"));
545+
}
546+
// the library folder itself, and its own top-level folders (`Originals`, `thumbs`), stay where
547+
// the library expects them; folders below those (an import's date folders) can be renamed
548+
if s.library.as_ref().is_some_and(|l| l.dir.starts_with(src) || src.parent() == Some(l.dir.as_path())) {
543549
return Err("the library's own folders can't be moved here".into());
544550
}
545551
// Repairs retain their exact old paths, including those on surviving history entries.

‎crates/engine/src/faces_index.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ impl FacesState {
599599
self.in_flight.clear();
600600
self.retry_at = None;
601601
self.saved_at = None;
602+
self.task = None;
603+
self.peak = 0;
602604
self.epoch = self.epoch.wrapping_add(1);
603605
}
604606

‎crates/engine/src/merge.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ impl Session {
911911
info["id"] = json!(id.0);
912912
info["path"] = json!(path);
913913
info["bytes"] = json!(out.dng.len());
914+
// a repeated identical merge gives the verified result it already made (no new file, edits kept)
915+
info["reused"] = json!(reused);
914916
Ok(info)
915917
}
916918

‎crates/engine/src/tests_face_recognize.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,24 @@ fn face_scan_row_follows_pending_photos() {
524524
let _ = std::fs::remove_dir_all(&d);
525525
}
526526

527+
#[test]
528+
fn face_scan_row_starts_over_in_another_library() {
529+
// issue #2995: the scan's whole was kept from the library opened before, so a smaller one showed most of it done
530+
let d = temp("peak-library");
531+
let (mut s, _) = setup(&d, 64);
532+
s.faces.peak = 442_717;
533+
s.open_library(d.join("other"), true).unwrap();
534+
let id = s.catalog.photos().map(|p| p.id).max().unwrap();
535+
set_regions(&mut s, id, vec![region(0.1, None)]);
536+
let last = s.execute("faces.pump", &json!({})).unwrap();
537+
let pending = last["pendingPhotos"].as_u64().unwrap();
538+
assert!(pending > 0, "{last}");
539+
assert_eq!(last["peak"].as_u64().unwrap(), pending, "{last}");
540+
let rows = s.activity.list().into_iter().filter(|t| t.kind == "faces").collect::<Vec<_>>();
541+
assert_eq!(rows.iter().map(|t| (t.total, t.done)).collect::<Vec<_>>(), vec![(pending, 0)]);
542+
let _ = std::fs::remove_dir_all(&d);
543+
}
544+
527545
fn face_names(s: &Session, id: PhotoId) -> Vec<Option<String>> {
528546
s.catalog.photo(id).unwrap().meta.regions.iter().map(|r| r.name.clone()).collect()
529547
}

‎crates/engine/src/tests_folders.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
1717
use lcc_catalog::{Op, Photo, Source};
1818
use serde_json::json;
19+
use std::path::Path;
1920

2021
use crate::{LibrarySource, Session, filter_chips};
2122

@@ -841,3 +842,29 @@ fn a_destination_without_write_permission_reports_an_error_and_keeps_everything(
841842
}
842843
std::fs::set_permissions(dir.0.join("ro"), std::fs::Permissions::from_mode(0o755)).unwrap();
843844
}
845+
846+
#[test]
847+
fn a_date_folder_inside_the_library_can_be_renamed_but_the_librarys_own_folders_cannot() {
848+
let dir = Scratch::new("in-library");
849+
let lib = dir.0.join("lib");
850+
let mut s = Session::new();
851+
s.open_library(&lib, false).unwrap();
852+
let day = lib.join("Originals").join("2026-10-16");
853+
std::fs::create_dir_all(&day).unwrap();
854+
add(&mut s, &day.join("a.jpg").to_string_lossy());
855+
let day = day.to_string_lossy().to_string();
856+
s.execute("folder.rename", &json!({"path": day, "name": "Beach"})).unwrap();
857+
assert!(lib.join("Originals/Beach").is_dir(), "the imported date folder is renamed");
858+
assert!(!Path::new(&day).exists());
859+
s.execute("edit.undo", &json!({})).unwrap();
860+
assert!(Path::new(&day).is_dir(), "undo names it back");
861+
for own in ["Originals", "thumbs"] {
862+
std::fs::create_dir_all(lib.join(own)).unwrap();
863+
let path = lib.join(own).to_string_lossy().to_string();
864+
assert!(s.execute("folder.rename", &json!({"path": path, "name": "x"})).is_err(), "{own} stays put");
865+
}
866+
assert!(s.execute("folder.rename", &json!({"path": lib.to_string_lossy(), "name": "x"})).is_err(), "and so does the library");
867+
let alias = lib.join("Originals").join("..").join("Originals").to_string_lossy().to_string();
868+
assert!(s.execute("folder.rename", &json!({"path": alias, "name": "x"})).is_err(), "even named through '..'");
869+
assert!(lib.join("Originals").is_dir());
870+
}

‎crates/engine/src/tests_merge.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ fn hdr_merge_command_creates_and_imports_a_dng() {
145145
let r = s.execute("merge.hdr", &json!({"ids": ids, "autoSettings": true, "stack": true})).unwrap();
146146
let path = r["path"].as_str().unwrap();
147147
assert!(path.ends_with("IMG_0-HDR.dng"), "{path}");
148+
assert_eq!(r["reused"].as_bool(), Some(false));
148149
let id = lcc_catalog::PhotoId(r["id"].as_u64().unwrap());
149150
let p = s.catalog.photo(id).unwrap().clone();
150151
assert_eq!((p.width, p.height), (480, 320));
@@ -168,6 +169,7 @@ fn hdr_merge_command_creates_and_imports_a_dng() {
168169
let undo_before = s.undo.len();
169170
let r2 = s.execute("merge.hdr", &json!({"ids": ids, "autoSettings": true, "stack": true})).unwrap();
170171
assert_eq!(r2["id"].as_u64(), Some(id.0));
172+
assert_eq!(r2["reused"].as_bool(), Some(true));
171173
assert_eq!(r2["path"].as_str(), Some(path));
172174
assert!(!dir.join("IMG_0-HDR-2.dng").exists(), "duplicate merge left an orphan");
173175
assert_eq!(s.catalog.photos().count(), 4);

0 commit comments

Comments
 (0)