Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
ed9cb0b
FX-187: an export batch that stops part-way still reports, marks and …
blwfish Dec 1, 2026
eae8294
FX-190: under Skip, a name the same export wrote gets a number instea…
blwfish Dec 1, 2026
77b6637
FX-189: an Exif block that can't be written fails the export instead …
blwfish Dec 1, 2026
557d0c7
Drop local ticket IDs from comments
clydecbrown Dec 1, 2026
d054df3
FX-188: TIFF exports carry EXIF; OpenEXR exports say which metadata t…
blwfish Dec 1, 2026
3ffe4a5
FX-195: HDR JPEG XL with Lossless on declares its samples PQ
blwfish Dec 1, 2026
33c6645
FX-241: pin the metadata chunks of every export writer and the metada…
blwfish Dec 1, 2026
76495e4
FX-191: a preset's format is refused against a path that names anothe…
blwfish Dec 1, 2026
7e6fb5d
FX-192: Choose folder later asks every time, also for Export with Pre…
blwfish Dec 1, 2026
74eb42b
FX-193: Export with Several Presets run as a command runs plug-in hoo…
blwfish Dec 1, 2026
ff103f9
FX-194: DNG export reads the raw with the camera's chosen decoder
blwfish Dec 1, 2026
2047b5c
FX-197: Email Photo holds a video clip to the same long edge
blwfish Dec 1, 2026
70c625c
Merge remote-tracking branch 'origin/staging' into fix/fx-187-190-bat…
blwfish Dec 1, 2026
5149a61
Merge remote-tracking branch 'origin/staging' into fix/fx-188-189-195…
blwfish Dec 1, 2026
6f87d01
Merge remote-tracking branch 'origin/staging' into fix/fx-193-run-pre…
blwfish Dec 1, 2026
bea8f22
Merge remote-tracking branch 'origin/staging' into fix/fx-191-192-exp…
blwfish Dec 1, 2026
45ee95f
Merge remote-tracking branch 'origin/staging' into fix/fx-194-dng-exp…
blwfish Dec 1, 2026
4f5d545
Merge remote-tracking branch 'origin/staging' into fix/fx-197-email-p…
blwfish Dec 1, 2026
1e033b6
FX-184: put watermark_from_json's doc comment back
blwfish Dec 1, 2026
11792a5
Merge origin/staging into fix/export-watermark-doc-nit
blwfish Dec 1, 2026
5fb54d7
#1795: Smart albums: smart preview, snapshots, label text and metadat…
clydecbrown Dec 1, 2026
a3e4e7d
FX-196: a .cube look's title can't carry line breaks into the file
blwfish Dec 1, 2026
58c8d86
Merge remote-tracking branch 'origin/staging' into fix/fx-196-cube-ti…
blwfish Dec 1, 2026
49a766b
Merge pull request #1793 from blwfish/fix/export-watermark-doc-nit
emmertex Dec 1, 2026
4495782
Merge pull request #1796 from clydecbrown/classic/fix/smart-status-cr…
emmertex Dec 1, 2026
0d7d55b
#1797: Plug-in install and uninstall refuse when ids clash with a pix…
clydecbrown Dec 1, 2026
6a6b36e
#1807: Duplicate smart collections and collection sets
clydecbrown Dec 1, 2026
a45a13c
Merge origin/staging into chore/drop-local-ticket-ids
clydecbrown Dec 1, 2026
5321fb7
Merge pull request #1798 from clydecbrown/classic/fix/b-9d7e
emmertex Dec 1, 2026
be942d0
Merge remote-tracking branch 'origin/staging' into fix/fx-187-190-bat…
blwfish Dec 1, 2026
9f6dc87
Merge remote-tracking branch 'origin/staging' into fix/fx-194-dng-exp…
blwfish Dec 1, 2026
c4656be
Merge remote-tracking branch 'origin/staging' into fix/fx-197-email-p…
blwfish Dec 1, 2026
62d6239
Merge remote-tracking branch 'origin/staging' into fix/fx-196-cube-ti…
blwfish Dec 1, 2026
94f98ea
Merge remote-tracking branch 'origin/staging' into fix/fx-188-189-195…
blwfish Dec 1, 2026
2670af5
Merge remote-tracking branch 'origin/staging' into fix/fx-193-run-pre…
blwfish Dec 1, 2026
a3320f5
Merge pull request #1803 from blwfish/fix/fx-194-dng-export-decoder-c…
emmertex Dec 1, 2026
8b0b5d1
Merge pull request #1805 from blwfish/fix/fx-197-email-photo-video-size
emmertex Dec 1, 2026
2cde75e
Merge pull request #1804 from blwfish/fix/fx-196-cube-title-newline
emmertex Dec 1, 2026
46d6471
Merge pull request #1801 from blwfish/fix/fx-187-190-batch-placement
emmertex Dec 1, 2026
776d221
FX-221: export preset import reports each preset and zip entry it ski…
blwfish Dec 1, 2026
3d0ab19
Merge pull request #1802 from blwfish/fix/fx-188-189-195-export-metadata
emmertex Dec 1, 2026
d017f2e
FX-223: Lightroom export preset import reads colour-space names throu…
blwfish Dec 1, 2026
1d3b7af
FX-222: Lightroom export preset import names every setting it cannot …
blwfish Dec 1, 2026
83e740e
Merge remote-tracking branch 'origin/staging' into fix/fx-193-run-pre…
blwfish Dec 1, 2026
a83330a
#1732: On This Day: controls in every layout, and the view keeps to i…
emmertex Dec 1, 2026
68e678d
Merge remote-tracking branch 'origin/staging' into fix/memories-followup
emmertex Dec 1, 2026
335dc94
FX-224: a file name from a long title, creator or folder is cut to th…
blwfish Dec 1, 2026
70159ad
#1811: Plug-in jobs hold their catalog writes and apply them as one u…
clydecbrown Dec 1, 2026
c21c7d6
FX-226: a WebP larger than the format takes is refused before it renders
blwfish Dec 1, 2026
ded9f95
FX-238: the numeric export options keep one set of accepted ranges
blwfish Dec 1, 2026
81e8fc3
Merge pull request #1809 from emmertex/fix/memories-followup
emmertex Dec 1, 2026
95ced31
#1813: Plug-in Manager log says where each line came from
clydecbrown Dec 1, 2026
8a268a0
FX-225: the Export dialog's file-name help describes export, with {cu…
blwfish Dec 1, 2026
5ea6603
Merge remote-tracking branch 'origin/staging' into fix/fx-221-223-pre…
blwfish Dec 1, 2026
1dd0e28
Merge remote-tracking branch 'origin/staging' into fix/fx-224-226-238…
blwfish Dec 1, 2026
c077720
Merge pull request #1810 from blwfish/fix/fx-193-run-presets-after-ex…
emmertex Dec 2, 2026
558cf1d
Merge pull request #1808 from clydecbrown/classic/chore/drop-local-ti…
emmertex Dec 2, 2026
f08594e
Merge pull request #1812 from clydecbrown/classic/feat/job-held-writes
emmertex Dec 2, 2026
da35a21
#1815: Clicking a collection set's name shows its photos
clydecbrown Dec 2, 2026
325ee53
Merge pull request #1814 from clydecbrown/classic/feat/plugin-log-sou…
emmertex Dec 2, 2026
9a5c174
Merge remote-tracking branch 'origin/staging' into fix/fx-191-192-exp…
blwfish Dec 2, 2026
bf07017
Merge remote-tracking branch 'origin/staging' into fix/fx-221-223-pre…
blwfish Dec 2, 2026
75fed69
Merge remote-tracking branch 'origin/staging' into fix/fx-191-192-exp…
blwfish Dec 2, 2026
bf1a74c
#1820: Smart albums: Develop state fields and their Lightroom criteria
clydecbrown Dec 2, 2026
00e143c
Merge pull request #1816 from clydecbrown/classic/fix/b-37fa
emmertex Dec 2, 2026
2331499
Merge pull request #1818 from blwfish/fix/fx-221-223-preset-import-re…
emmertex Dec 2, 2026
4364f54
#1822: Preset Amount slider stays after visiting another photo
clydecbrown Dec 2, 2026
082f182
Merge origin/staging into fix/fx-191-192-export-params-and-last
blwfish Dec 2, 2026
77f6ac5
Merge pull request #1821 from clydecbrown/classic/feat/smart-develop-…
emmertex Dec 2, 2026
078fe0c
Merge pull request #1823 from clydecbrown/classic/fix/preset-amount-a…
emmertex Dec 2, 2026
8b416e8
Merge remote-tracking branch 'origin/staging' into fix/fx-191-192-exp…
blwfish Dec 2, 2026
74b287d
Merge origin/staging into fix/fx-224-226-238-225-export-names-and-limits
blwfish Dec 2, 2026
4564de7
Merge pull request #1824 from blwfish/fix/fx-191-192-export-params-an…
emmertex Dec 2, 2026
bc51c5f
#1825: Smart albums: AI edit, mask and retouch fields and their Light…
clydecbrown Dec 2, 2026
1f975ea
Merge remote-tracking branch 'origin/staging' into sync/main-to-stagi…
emmertex Dec 2, 2026
6cf725d
Merge pull request #1828 from emmertex/sync/main-to-staging-2026-12-02
emmertex Dec 2, 2026
a811c0c
Merge origin/staging into fix/fx-224-226-238-225-export-names-and-limits
blwfish Dec 2, 2026
a5592fd
Merge pull request #1826 from clydecbrown/classic/feat/smart-ai-criteria
emmertex Dec 2, 2026
abe3a6f
FX-218: Export with Several Presets: cancel interrupts the photo in f…
blwfish Dec 2, 2026
c837048
FX-220: Export with Several Presets: the shared decode is guarded and…
blwfish Dec 2, 2026
61c4c17
#1830: Say "the app" in the Lightroom import notes
clydecbrown Dec 2, 2026
afdcf22
#1830: Smart albums: Published Via and Publish Collection fields and …
clydecbrown Dec 2, 2026
bebab01
Merge pull request #1829 from blwfish/fix/fx-224-226-238-225-export-n…
emmertex Dec 2, 2026
8e1e0be
FX-242: the 32-preset cap of Export with Several Presets is pinned by…
blwfish Dec 2, 2026
f7277c4
Run presets: record each exported photo once
blwfish Dec 2, 2026
951d243
Merge pull request #1831 from clydecbrown/classic/feat/smart-publish-…
emmertex Dec 2, 2026
d40e347
Issue #1832: fit the AI orientation classifier in Settings ▸ AI Models
1234destiny1234 Dec 2, 2026
0340bc0
Merge remote-tracking branch 'refs/remotes/upstream/staging' into are…
1234destiny1234 Dec 2, 2026
3e4a00d
Document Orientation classifier section in Settings reference
1234destiny1234 Dec 2, 2026
f2e7a4d
Merge remote-tracking branch 'origin/staging' into fix/fx-218-220-242…
blwfish Dec 2, 2026
f63e57d
Merge pull request #1833 from 1234destiny1234/arena/bc17b3cf-lightcra…
emmertex Dec 2, 2026
db8f86c
FX-214: an Overwrite export writes a photo's file and sidecars as a g…
blwfish Dec 2, 2026
a3e7acf
FX-216: the CLI's render and Exported::save write an export through o…
blwfish Dec 2, 2026
ce36318
Raw decoder: dnglab (rawler) as a third per-camera decoder
claude Dec 2, 2026
d4c8921
Merge pull request #1835 from blwfish/fix/fx-218-220-242-run-presets-…
emmertex Dec 2, 2026
0f46d5c
FX-239: encode_jpeg has one JPEG writer; the unreachable 4:2:2 branch…
blwfish Dec 2, 2026
2313799
FX-215: a JPEG export of very long metadata leaves out the largest fi…
blwfish Dec 2, 2026
e10cf40
FX-240: the codecs EXIF walker reads a directory with lcc-tiff's entr…
blwfish Dec 2, 2026
e22e211
Merge remote-tracking branch 'origin/staging' into claude/project-thr…
claude Dec 2, 2026
c68c1a0
Raw decoder: rawler as a workspace dependency
claude Dec 2, 2026
9bd81d2
Raw decoder: allow rawler's LGPL-2.1 licence id in cargo deny
claude Dec 2, 2026
6447c87
Raw decoder: lcc-dnglab builds for wasm32 without rawler
claude Dec 2, 2026
0b4b305
FX-217: the export commands are refused while another export runs, an…
blwfish Dec 2, 2026
2503d5b
FX-227: Export with Several Presets is greyed out in the web build an…
blwfish Dec 2, 2026
53d2846
FX-236: each export format's bit depth, alpha and HDR behaviour comes…
blwfish Dec 2, 2026
a3f8374
FX-235: clashing file names are numbered by one rule, and none falls …
blwfish Dec 2, 2026
c55514b
FX-237: the colour profile, Exif block and XMP packet are put togethe…
blwfish Dec 2, 2026
cfbf73a
Merge remote-tracking branch 'origin/staging' into fix/fx-214-216-exp…
blwfish Dec 2, 2026
1f0bf5a
Merge remote-tracking branch 'origin/staging' into fix/fx-215-239-240…
blwfish Dec 2, 2026
2d1d668
Issue #1832: paintable menu arrows in the Auto Orient translations
emmertex Dec 2, 2026
dec10ea
Merge pull request #1841 from blwfish/fix/fx-217-227-run-presets-comm…
emmertex Dec 2, 2026
a49b2b5
Merge pull request #1842 from blwfish/fix/fx-235-free-file-names
emmertex Dec 2, 2026
fe557ec
Merge pull request #1839 from blwfish/fix/fx-214-216-export-writes
emmertex Dec 2, 2026
613f214
Merge pull request #1840 from blwfish/fix/fx-215-239-240-export-metad…
emmertex Dec 2, 2026
50cbd53
Merge pull request #1843 from blwfish/fix/fx-236-237-export-depth-and…
emmertex Dec 2, 2026
589f5a3
Merge remote-tracking branch 'origin/staging' into fix/nightly-2026-1…
emmertex Dec 2, 2026
0ef9810
Merge pull request #1844 from emmertex/fix/nightly-2026-12-03-menu-tr…
emmertex Dec 2, 2026
b5269a2
Merge branch 'staging' into claude/project-thread-shahjb
emmertex Dec 2, 2026
1f95f54
Merge pull request #1836 from emmertex/claude/project-thread-shahjb
emmertex Dec 2, 2026
e993489
#1845: one opt-out for the tests that start the device-sync service
clydecbrown Dec 2, 2026
49831ca
Merge pull request #1846 from clydecbrown/classic/fix/lan-tests-opt-out
emmertex Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 180 additions & 22 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ lcc-faces = { path = "crates/faces" }
lcc-sysmem = { path = "crates/sysmem" }
lcc-diag = { path = "crates/diag" }
lcc-libraw = { path = "crates/libraw" }
lcc-dnglab = { path = "crates/dnglab" }
lcc-hdrmeta = { path = "crates/hdrmeta" }
lcc-gpumem = { path = "crates/gpumem" }
lcc-onnxrt = { path = "crates/onnxrt" }
Expand Down Expand Up @@ -103,6 +104,8 @@ base64 = "0.22"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
log = "0.4"
# dnglab's raw decoder library (LGPL-2.1), used only by crates/dnglab
rawler = { version = "0.8", default-features = false }
# the control port token (`apps/app`)
getrandom = "0.3"
# All date/time conversion goes through chrono (no hand-rolled calendar code beyond the 400-year range extension; CLAUDE.md).
Expand Down
6 changes: 6 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ used under the GNU LGPL 2.1 (crates/libraw/LICENSE-LibRaw-LGPL-2.1.txt; LibRaw a
binary is offered under GPL-3.0-or-later. The source of the LibRaw version built is at that address; the
crate's C shim (crates/libraw/shim/shim.cpp) is our own work and calls LibRaw's public API only.

Builds with the `dnglab` feature (the desktop app and the CLI, see crates/dnglab) contain rawler
(https://github.com/dnglab/dnglab, the crates.io `rawler` crate), the decoder library of the dnglab project,
Copyright Daniel Vogelbacher, Pedro Côrte-Real and the dnglab contributors, unmodified, used under the GNU LGPL 2.1
(crates/dnglab/LICENSE-rawler-LGPL-2.1.txt); such a binary is offered under GPL-3.0-or-later. The wrapper in
crates/dnglab is our own work and calls rawler's public API only.

crates/pipeline/src/tone_eq.rs (the Tone Equalizer) is translated from darktable's src/iop/toneequal.c
(https://github.com/darktable-org/darktable), Copyright 2018-2026 Aurélien Pierre and the darktable developers,
used under the GNU GPL 3.0 or later (LICENSE-GPL-3.0.txt): the nine-band Gaussian radial-basis correction curve
Expand Down
4 changes: 3 additions & 1 deletion apps/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ workspace = true

[features]
# The upstream project's own AI Denoise model (MIT OR Apache-2.0) is offered as a download
default = ["denoise", "own-model", "heif", "onnxruntime", "libraw"]
default = ["denoise", "own-model", "heif", "onnxruntime", "libraw", "dnglab"]
denoise = ["lcc-engine/denoise", "lcc-cli/denoise"]
rawnind-model = ["denoise", "lcc-engine/rawnind-model", "lcc-cli/rawnind-model"]
realesrgan-model = ["denoise", "lcc-engine/realesrgan-model", "lcc-cli/realesrgan-model"]
Expand All @@ -33,6 +33,8 @@ audio-out = ["lcc-engine/audio-out"]
# LibRaw as a per-camera raw decoder (C++; linked only when LIBRAW_DIR or LIBRAW_SYSTEM=1 is set, see
# crates/libraw/build.rs; otherwise Settings shows it unavailable).
libraw = ["lcc-engine/libraw", "lcc-cli/libraw"]
# dnglab's decoder (rawler, pure Rust) as a per-camera raw decoder.
dnglab = ["lcc-engine/dnglab", "lcc-cli/dnglab"]

[dependencies]
# the command-line tool, run when the program is started as `<cli>` (`main`); its features follow
Expand Down
4 changes: 3 additions & 1 deletion apps/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ serde_json = { workspace = true }
dhat = { workspace = true, optional = true }

[features]
default = ["denoise", "heif", "libraw"]
default = ["denoise", "heif", "libraw", "dnglab"]
denoise = ["lcc-engine/denoise"]
rawnind-model = ["denoise", "lcc-engine/rawnind-model"]
realesrgan-model = ["denoise", "lcc-engine/realesrgan-model"]
Expand All @@ -59,6 +59,8 @@ dhat-heap = ["dep:dhat"]
# LibRaw as a per-camera raw decoder (C++; linked only when LIBRAW_DIR or LIBRAW_SYSTEM=1 is set, see
# crates/libraw/build.rs, otherwise the choice is shown as unavailable).
libraw = ["lcc-engine/libraw"]
# dnglab's decoder (rawler, pure Rust) as a per-camera raw decoder.
dnglab = ["lcc-engine/dnglab"]

# Open HEIC/HEIF photos (the lcc-heif crate, pure Rust). On by default, as in the app;
# `--no-default-features --features denoise` leaves HEVC out.
Expand Down
13 changes: 3 additions & 10 deletions apps/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,16 +1134,9 @@ fn render(args: &[String]) -> Result<(), String> {
// Add to Apple Photos: refused before anything is written when it can't be done
let after = s.after_export(&o)?;
let e = export_photo(&mut s, lcc_engine::catalog::PhotoId(id), &o, 1)?;
// never over the input (or its sidecar), however it is spelled: `render IMG.jpg -o IMG.jpg`
let sidecars: Vec<(String, &Vec<u8>)> =
e.sidecars.iter().map(|(ext, bytes)| (Path::new(&output).with_extension(ext).to_string_lossy().to_string(), bytes)).collect();
let guard = s.original_guard();
for p in std::iter::once(&output).chain(sidecars.iter().map(|(p, _)| p)) {
guard.check(Path::new(p)).map_err(|err| format!("render: {err}"))?;
}
e.save(&output)?;
for (sc, bytes) in &sidecars {
lcc_engine::export::write_file(sc, bytes)?;
// never over the input (or its sidecar), however it is spelled (`render IMG.jpg -o IMG.jpg`), and the sidecars named as
// every export names them: the engine's one writer of an export to a path
for sc in e.save(&output, &s.original_guard()).map_err(|err| format!("render: {err}"))? {
eprintln!("{CLI}: wrote {sc}");
}
let limit =
Expand Down
29 changes: 29 additions & 0 deletions apps/cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,35 @@ fn render_export_options() {
assert!(!o.status.success() && String::from_utf8_lossy(&o.stderr).contains("unknown extension"));
}

/// FX-216: `render` names an Original's sidecar as every export does (everything before the last dot is the stem), and
/// writes a file and its sidecar or neither: a sidecar that can't be written (its name is a folder) leaves no copy of the
/// file, and the error names it (FX-214).
#[test]
fn render_names_its_sidecar_like_every_export_and_writes_both_or_neither() {
let input = tmp("sc-in.png");
gradient_png(&input);
let dir = input.parent().unwrap().to_path_buf();
let render = |out: &std::path::Path| {
Command::new(BIN)
.args(["render", input.to_str().unwrap(), "-o", out.to_str().unwrap(), "--set", "light.exposure=1", "--opt", "format=original"])
.output()
.unwrap()
};
// several dots: the stem is everything before the last one
let out = dir.join("album.v1.final.png");
let o = render(&out);
assert!(o.status.success(), "{}", String::from_utf8_lossy(&o.stderr));
assert!(dir.join("album.v1.final.xmp").is_file(), "the sidecar takes the stem");
assert!(!dir.join("album.xmp").exists() && !dir.join("album.v1.xmp").exists());
// a sidecar that can't be written: no copy without it
let out = dir.join("copy.png");
std::fs::create_dir(dir.join("copy.xmp")).unwrap();
let o = render(&out);
let err = String::from_utf8_lossy(&o.stderr);
assert!(!o.status.success() && err.contains("copy.xmp"), "{err}");
assert!(!out.exists(), "a copy without its edits was left behind");
}

#[test]
fn commands_subcommand_lists_registry() {
let o = Command::new(BIN).args(["commands", "--json"]).output().unwrap();
Expand Down
20 changes: 18 additions & 2 deletions crates/camprof/src/jpeg_look.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ pub struct CameraLook {
impl CameraLook {
/// The look as `.cube` text titled `title`.
pub fn to_cube(&self, title: &str) -> String {
let clean: String = title.chars().filter(|c| *c != '"' && !c.is_control()).collect();
let mut s = format!("TITLE \"{clean}\"\nLUT_3D_SIZE {GRID}\n");
let mut s = String::new();
if let Some(t) = lcc_color::cube::title_text(title) {
s.push_str(&format!("TITLE \"{t}\"\n"));
}
s.push_str(&format!("LUT_3D_SIZE {GRID}\n"));
for c in &self.table {
s.push_str(&format!("{:.6} {:.6} {:.6}\n", c[0], c[1], c[2]));
}
Expand Down Expand Up @@ -374,4 +377,17 @@ mod tests {
assert!(t.starts_with("TITLE \"My Cam\"\n"));
assert_eq!(t.lines().filter(|l| l.starts_with(|c: char| c.is_ascii_digit())).count(), GRID * GRID * GRID);
}

/// FX-196: a title with line breaks can't write lines of its own, and a title with nothing left writes no line.
#[test]
fn a_title_cannot_inject_lines_into_the_cube_text() {
let look = fit(&synthetic(5000)).unwrap();
let t = look.to_cube("a\r\nDOMAIN_MAX 8 8 8\nLUT_3D_SIZE 3");
assert!(t.starts_with("TITLE \"a DOMAIN_MAX 8 8 8 LUT_3D_SIZE 3\"\nLUT_3D_SIZE "), "{}", t.lines().take(3).collect::<Vec<_>>().join("|"));
assert_eq!(t.lines().filter(|l| l.starts_with("LUT_3D_SIZE")).count(), 1);
assert_eq!(t.lines().filter(|l| l.starts_with("DOMAIN")).count(), 0);
for empty in ["", "\n", "\r\n", "\"", " \t "] {
assert!(look.to_cube(empty).starts_with("LUT_3D_SIZE "), "{empty:?}");
}
}
}
2 changes: 1 addition & 1 deletion crates/catalog/src/facets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn aspect(p: &Photo) -> Option<String> {
fn presets(p: &Photo) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
for step in &p.history {
if let Some(name) = step.label.strip_prefix("Preset: ").map(str::trim).filter(|n| !n.is_empty())
if let Some(name) = step.label.strip_prefix(crate::model::PRESET_STEP_PREFIX).map(str::trim).filter(|n| !n.is_empty())
&& !out.iter().any(|o| o.eq_ignore_ascii_case(name))
{
out.push(name.to_string());
Expand Down
4 changes: 4 additions & 0 deletions crates/catalog/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub(crate) struct Indexes {
stacks: OnceLock<Option<HashMap<PhotoId, StackId>>>,
/// Album → its photos (regular albums; a smart album's list is empty).
albums: OnceLock<HashMap<AlbumId, HashSet<PhotoId>>>,
/// Collection set → the collections inside it, at any depth ([`Catalog::folder_collections`]);
/// dropped by any op that adds, removes or moves an album, or changes rules.
pub(crate) folder_collections: OnceLock<HashMap<AlbumId, Vec<AlbumId>>>,
/// Folder ([`photo_folder_index_key`], lower-cased) → the photos whose file is directly in it,
/// whatever their state (library, Recently Deleted, browsed in Local). Demo photos have none.
folders: OnceLock<HashMap<String, HashSet<PhotoId>>>,
Expand Down Expand Up @@ -213,6 +216,7 @@ impl Indexes {
/// An album came, went or got other rules: whether a smart album asks about contents is asked again.
pub(crate) fn albums_changed(&mut self) {
self.contents_asked = OnceLock::new();
self.folder_collections = OnceLock::new();
}
}

Expand Down
116 changes: 113 additions & 3 deletions crates/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,35 @@ pub struct Catalog {
/// Lookups derived from the above (never saved), see [`index`].
#[serde(skip)]
index: index::Indexes,
/// The photos that have a smart preview on disk, as the engine last listed them (never saved; empty until it
/// does), for the Has Smart Preview rule.
#[serde(skip)]
smart_previews: SmartPreviewSet,
/// The names of the publish services, by service id, as the engine last listed them (never saved; empty until it
/// does), for the Published Via rule: the names live in `publish.json`, which the catalog never reads.
#[serde(skip)]
publish_services: PublishServiceNames,
}

/// [`Catalog::set_publish_services`]'s names. Compares equal whatever it holds, like [`SmartPreviewSet`].
#[derive(Clone, Debug, Default)]
struct PublishServiceNames(Arc<BTreeMap<String, String>>);

impl PartialEq for PublishServiceNames {
fn eq(&self, _: &Self) -> bool {
true
}
}

/// [`Catalog::set_smart_previews`]'s photos. Compares equal whatever it holds, like [`index::Indexes`]: it is
/// what the disk holds, not part of the library.
#[derive(Clone, Debug, Default)]
struct SmartPreviewSet(Arc<std::collections::HashSet<PhotoId>>);

impl PartialEq for SmartPreviewSet {
fn eq(&self, _: &Self) -> bool {
true
}
}

/// What of a photo an op changed: enough to tell which tallies of the library an edit leaves as they were (a
Expand Down Expand Up @@ -647,14 +676,58 @@ impl Catalog {
/// Albums (regular and smart) that contain the photo.
pub fn albums_of(&self, id: PhotoId) -> Vec<AlbumId> {
let Some(p) = self.photos.get(&id) else { return Vec::new() };
self.albums.values().filter(|a| self.album_contains(a.id, p)).map(|a| a.id).collect()
self.albums.values().filter(|a| !a.folder && self.album_contains(a.id, p)).map(|a| a.id).collect()
}

/// The collections inside folder `id`, at any depth (not the folders themselves), worked out
/// for every folder on first use and kept until an album comes, goes, moves or gets other rules. A saved loop of
/// parents ends the walk: each folder is visited once, and the depth is bounded.
fn folder_collections(&self, id: AlbumId) -> &[AlbumId] {
const MAX_DEPTH: usize = 64;
let all = self.index.folder_collections.get_or_init(|| {
let mut kids: std::collections::HashMap<AlbumId, Vec<&Album>> = std::collections::HashMap::new();
for a in self.albums.values() {
if let Some(p) = a.parent {
kids.entry(p).or_default().push(a);
}
}
let mut all = std::collections::HashMap::new();
for f in self.albums.values().filter(|a| a.folder) {
let mut seen: std::collections::HashSet<AlbumId> = std::collections::HashSet::from([f.id]);
let mut out = Vec::new();
let mut level = vec![f.id];
for _ in 0..MAX_DEPTH {
let mut next = Vec::new();
for a in level.iter().filter_map(|l| kids.get(l)).flatten() {
if !seen.insert(a.id) {
continue;
}
if a.folder {
next.push(a.id);
} else {
out.push(a.id);
}
}
if next.is_empty() {
break;
}
level = next;
}
out.sort_unstable();
all.insert(f.id, out);
}
all
});
all.get(&id).map_or(&[], Vec::as_slice)
}

/// Whether album `id` contains `p` (a smart album evaluates its rules; deleted photos are in
/// no smart album).
/// no smart album; a collection set holds what the collections inside it hold, at any depth).
pub fn album_contains(&self, id: AlbumId, p: &Photo) -> bool {
match self.albums.get(&id) {
Some(Album { smart: Some(rules), .. }) => self.smart_album_has(id, rules, &rules.prepare_one(), p),
// a folder (a collection set) holds what its collections hold, at any depth
Some(a) if a.folder => self.folder_collections(a.id).iter().any(|c| self.album_contains(*c, p)),
Some(a) => self.album_lists(a.id, p.id),
None => false,
}
Expand Down Expand Up @@ -720,6 +793,11 @@ impl Catalog {
let prepared = rules.prepare();
self.photos.values().filter(|p| self.smart_album_has(id, rules, &prepared, p)).map(|p| p.id).collect()
}
Some(a) if a.folder => {
// each photo once, in id order
let held: std::collections::BTreeSet<PhotoId> = self.folder_collections(a.id).iter().flat_map(|c| self.album_photos(*c)).collect();
held.into_iter().collect()
}
Some(a) => a.photos.clone(),
None => Vec::new(),
}
Expand Down Expand Up @@ -751,6 +829,36 @@ impl Catalog {
Ok(())
}

/// Tell the catalog which photos have a smart preview on disk (the engine lists them: the catalog never
/// reads files). Changes what the Has Smart Preview rule matches, so it counts as a change for what is
/// keyed by [`Catalog::revision`].
pub fn set_smart_previews(&mut self, ids: std::collections::HashSet<PhotoId>) {
if *self.smart_previews.0 != ids {
self.smart_previews = SmartPreviewSet(Arc::new(ids));
self.revision = self.revision.wrapping_add(1);
}
}

/// Whether `id` is among the photos last given to [`Catalog::set_smart_previews`].
pub fn has_smart_preview(&self, id: PhotoId) -> bool {
self.smart_previews.0.contains(&id)
}

/// Tell the catalog the name of each publish service, by service id (the engine reads them from `publish.json`:
/// the catalog never reads files). Changes what the Published Via rule matches, so it counts as a change for what
/// is keyed by [`Catalog::revision`].
pub fn set_publish_services(&mut self, names: BTreeMap<String, String>) {
if *self.publish_services.0 != names {
self.publish_services = PublishServiceNames(Arc::new(names));
self.revision = self.revision.wrapping_add(1);
}
}

/// The name of publish service `id`, as last given to [`Catalog::set_publish_services`].
pub fn publish_service_name(&self, id: &str) -> Option<&str> {
self.publish_services.0.get(id).map(String::as_str)
}

/// The name of a colour label: its custom name, else the colour (`Red`).
pub fn label_name(&self, l: ColorLabel) -> String {
self.label_names.get(&l).cloned().unwrap_or_else(|| format!("{l:?}"))
Expand Down Expand Up @@ -944,7 +1052,7 @@ impl Catalog {
_ => None,
}
.filter(|_| self.follows_contents());
let albums = matches!(op, Op::AddAlbum { .. } | Op::RemoveAlbum { .. } | Op::SetAlbumRules { .. });
let albums = matches!(op, Op::AddAlbum { .. } | Op::RemoveAlbum { .. } | Op::MoveAlbum { .. } | Op::SetAlbumRules { .. });
let before = photo.and_then(|id| self.content_of(id));
let inv = self.apply_op(op)?;
if let Some(id) = photo {
Expand Down Expand Up @@ -1950,6 +2058,8 @@ mod tests_folder_index;
#[cfg(test)]
mod tests_folder_records;
#[cfg(test)]
mod tests_folder_union;
#[cfg(test)]
mod tests_folders;
#[cfg(test)]
mod tests_follow;
Expand Down
Loading
Loading