Skip to content

Commit 3eada64

Browse files
AlexChambersclaude
andcommitted
LR-CLOUD-SMARTPREVIEW: PR storytold#850's JPEG encode version applies to Compact proxies only (storytold#709)
With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a Compact header records its encode version (`enc: 2`); one from an older encoding is rebuilt like one from an older camera look. The Lossless header uses the same `enc` field for its own format version (1), which reading the file checks, so `is_stale` applies the encode version to Compact proxies only (resolved in the first two commits of this branch while rebasing onto it). marker and the per-replacement clear like a look refresh. Test: a photo with the per-file camera look; its Compact proxy from before the encode version is rebuilt once, then its Lossless proxy is kept by Build and by the opening scan of a folder checked before the encode version. Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e2ba9e3 commit 3eada64

17 files changed

Lines changed: 337 additions & 22 deletions

‎crates/engine/src/media.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,8 @@ impl RenderJob {
10171017
}
10181018
let histogram = Histogram::of_srgb8(&image);
10191019
return RenderResult {
1020+
cache_generation: self.cache_generation,
1021+
cache_owner: self.cache_owner.clone(),
10201022
request_id: self.request_id,
10211023
source_key: self.source_key,
10221024
photo: self.photo,

‎crates/engine/src/slide_title.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ impl TitleCompose {
353353
let image = self.compose();
354354
let histogram = lightcraft_raster::Histogram::of_srgb8(&image);
355355
crate::media::RenderResult {
356+
cache_generation: 0,
357+
cache_owner: std::sync::Weak::new(),
356358
request_id,
357359
source_key: None,
358360
photo: lightcraft_catalog::PhotoId(0),

‎crates/engine/src/smart/tests_conversion.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ fn assert_thumbnail_matches_proxy(s: &mut Session, name: &str) {
120120
);
121121
}
122122

123-
/// Files the thumbnail cache does not own, left at the top of its folder.
123+
/// Worker markers and unexpected files at the top of the thumbnail folder.
124124
fn loose_files(root: &Path) -> Vec<PathBuf> {
125125
let Ok(entries) = std::fs::read_dir(root.join("library/thumbs")) else { return Vec::new() };
126-
entries.flatten().map(|e| e.path()).filter(|p| p.is_file()).collect()
126+
entries
127+
.flatten()
128+
.map(|e| e.path())
129+
.filter(|p| p.is_file() && p.file_name().is_none_or(|name| name != ".lightcraft-thumbs" && name != lightcraft_preview::disk::TAG))
130+
.collect()
127131
}
128132

129133
#[test]
@@ -647,7 +651,7 @@ fn interrupted_discard_then_build_child() {
647651
s.media.rendered.put(key, Arc::new(shown));
648652
set_online(&root, true);
649653
let hex = key.to_string();
650-
let fifo = root.join("library/thumbs").join(&hex[..2]).join(format!("{hex}.jpg"));
654+
let fifo = root.join("library/thumbs").join(&hex[..2]).join(format!("{hex}.{}", lightcraft_preview::disk::EXT));
651655
std::fs::remove_file(&fifo).unwrap();
652656
assert!(std::process::Command::new("mkfifo").arg(&fifo).status().unwrap().success());
653657
// a new cache object has an empty memory cache, so the read goes to the FIFO

‎crates/engine/src/smart/tests_round4.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn namespace_switch_does_not_wait_for_an_old_thumbnail_read() {
204204
let job = s.thumb_job(id, 128).unwrap();
205205
let (old_cache, key) = job.cache.clone().unwrap();
206206
let hex = key.to_string();
207-
let fifo = root.join("library/thumbs").join(&hex[..2]).join(format!("{hex}.jpg"));
207+
let fifo = root.join("library/thumbs").join(&hex[..2]).join(format!("{hex}.{}", lightcraft_preview::disk::EXT));
208208
let jpeg = std::fs::read(&fifo).unwrap();
209209
std::fs::remove_file(&fifo).unwrap();
210210
assert!(std::process::Command::new("mkfifo").arg(&fifo).status().unwrap().success());

‎crates/engine/src/tests_import.rs‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,63 @@ fn smart_previews_from_an_older_look_fit_are_refreshed() {
15311531
let _ = std::fs::remove_dir_all(&lib);
15321532
}
15331533

1534+
/// The encode version (JPEG quality and mapping) is Compact's: a Compact proxy from an older
1535+
/// encoding is rebuilt like one from an older look, but a Lossless proxy, whose header uses the same
1536+
/// `enc` field for its own format version, is current and is never rebuilt for it, by Build Smart
1537+
/// Previews or by the opening scan.
1538+
#[test]
1539+
fn the_compact_encode_version_does_not_rebuild_lossless_smart_previews() {
1540+
use std::sync::atomic::{AtomicUsize, Ordering};
1541+
let src = temp_dir("smartenc-src");
1542+
let lib = temp_dir("smartenc-lib");
1543+
write_png(&src.join("a.png"), 3);
1544+
let mut s = Session::new().with_fs();
1545+
s.open_library(&lib, false).unwrap();
1546+
s.execute("library.import", &json!({"paths": [src.join("a.png").to_string_lossy()]})).unwrap();
1547+
let id = s.catalog.photos().next().unwrap().id;
1548+
// a raw that takes the per-file camera look: the only photos whose proxies go stale
1549+
let mut raw = (**s.catalog.photo(id).unwrap()).clone();
1550+
raw.format = "ARW".into();
1551+
raw.kind = lightcraft_catalog::MediaKind::Raw;
1552+
s.catalog.apply(lightcraft_catalog::Op::RemovePhoto { id }).unwrap();
1553+
s.catalog.apply(lightcraft_catalog::Op::AddPhoto { photo: Box::new(raw) }).unwrap();
1554+
s.execute("library.select", &json!({"ids": [id.0], "active": id.0})).unwrap();
1555+
let dir = s.media.smart_dir.clone().unwrap();
1556+
let file = crate::smart::sharded_file_path(&dir, s.catalog.photo(id).unwrap());
1557+
let calls = std::sync::Arc::new(AtomicUsize::new(0));
1558+
let plain = s.media.file_loader.clone().unwrap();
1559+
s.media.file_loader = Some(look_loader(plain, test_tone(2.0), calls.clone()));
1560+
// Compact from before the encode version is rebuilt once
1561+
s.execute("library.smartPreviews", &json!({"format": "compact"})).unwrap();
1562+
edit_smart_header(&file, |h| {
1563+
h.as_object_mut().unwrap().remove("enc");
1564+
});
1565+
assert!(crate::smart::is_stale(&file));
1566+
let r = s.execute("library.smartPreviews", &json!({"format": "compact"})).unwrap();
1567+
assert_eq!(r["refreshed"], json!(1), "{r}");
1568+
assert_eq!(smart_header(&file)["enc"], json!(crate::smart::ENCODE_VERSION));
1569+
// Lossless keeps its own version, which reads lower than Compact's
1570+
s.execute("library.smartPreviews", &json!({"format": "lossless"})).unwrap();
1571+
let (storage, head) = crate::smart::header(&file).unwrap();
1572+
assert_eq!(storage, crate::smart::Format::Lossless);
1573+
assert!(head["enc"].as_u64().is_some_and(|enc| enc < crate::smart::ENCODE_VERSION), "{head}");
1574+
assert!(!crate::smart::is_stale(&file), "a current Lossless proxy is not out of date");
1575+
let lossless = std::fs::read(&file).unwrap();
1576+
calls.store(0, Ordering::SeqCst);
1577+
let r = s.execute("library.smartPreviews", &json!({"format": "lossless"})).unwrap();
1578+
assert_eq!((r["built"].as_u64(), r["refreshed"].as_u64()), (Some(1), Some(0)), "{r}");
1579+
assert_eq!(calls.load(Ordering::SeqCst), 0, "the original is not read again");
1580+
// and the opening scan, which a folder checked before the encode version runs once, keeps it
1581+
std::fs::write(dir.join("look-version"), format!("{}\n", crate::camera_preview::LOOK_VERSION)).unwrap();
1582+
assert!(!crate::smart::look_checked(&dir));
1583+
crate::cmd::previews::refresh_stale_smart_previews(&mut s).unwrap().join().unwrap();
1584+
assert_eq!(calls.load(Ordering::SeqCst), 0);
1585+
assert!(std::fs::read(&file).unwrap() == lossless, "the Lossless proxy is untouched");
1586+
assert!(crate::smart::look_checked(&dir));
1587+
let _ = std::fs::remove_dir_all(&src);
1588+
let _ = std::fs::remove_dir_all(&lib);
1589+
}
1590+
15341591
/// The look marker: missing, damaged or older than this build's fit version counts as unchecked.
15351592
#[test]
15361593
fn smart_preview_look_marker_is_read_safely() {

‎crates/ui-egui/locales/cs-formats.json‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@
169169
"the {} photos in view": "fotografie v zobrazení: {}",
170170
"these {count} photos": "tyto fotografie: {count}",
171171
"{:.1} MB": "{:.1} MB",
172-
"{count} smart preview{} · {:.1} MB": "Inteligentní náhledy: {count}{0:.0} · {1:.1} MB",
173172
"{done} of {total}": "{done} z {total}",
174173
"{done} of {total} MB": "{done} z {total} MB",
175174
"{file} · {size}": "{file} · {size}",
@@ -295,5 +294,35 @@
295294
"Already in “{}”": "Již v „{}“",
296295
"Move {n} photo{} to “{}”": "Přesunout do „{1}“ fotografie: {n}{0:.0}",
297296
"Move {n} photo{} to “{}”?": "Přesunout do „{1}“ fotografie: {n}{0:.0}?",
298-
"Moved {n} photo{} to “{}”. Edit → Undo moves them back.": "Do „{1}“ přesunuto fotografií: {n}{0:.0}. Úpravy → Zpět je vrátí."
297+
"Moved {n} photo{} to “{}”. Edit → Undo moves them back.": "Do „{1}“ přesunuto fotografií: {n}{0:.0}. Úpravy → Zpět je vrátí.",
298+
"Destination: {path}": "Cíl: {path}",
299+
"Estimated total size: {size}": "Odhadovaná celková velikost: {size}",
300+
"Free space: {size}": "Volné místo: {size}",
301+
"Smart preview folder change failed: {error}": "Změna složky inteligentních náhledů se nezdařila: {error}",
302+
"could not check smart preview storage: {e}": "úložiště inteligentních náhledů nelze zkontrolovat: {e}",
303+
"free space is unavailable for {path} on this platform": "na této platformě nelze zjistit volné místo pro {path}",
304+
"Photos: {count}": {
305+
"one": "Fotografie: {count}",
306+
"few": "Fotografie: {count}",
307+
"many": "Fotografie: {count}",
308+
"other": "Fotografie: {count}"
309+
},
310+
"{count} smart previews · {size:.1} MiB": {
311+
"one": "Inteligentní náhledy: {count} · {size:.1} MiB",
312+
"few": "Inteligentní náhledy: {count} · {size:.1} MiB",
313+
"many": "Inteligentní náhledy: {count} · {size:.1} MiB",
314+
"other": "Inteligentní náhledy: {count} · {size:.1} MiB"
315+
},
316+
". {count} existing previews kept unchanged": {
317+
"one": ". Ponechané existující náhledy: {count}",
318+
"few": ". Ponechané existující náhledy: {count}",
319+
"many": ". Ponechané existující náhledy: {count}",
320+
"other": ". Ponechané existující náhledy: {count}"
321+
},
322+
"Smart preview folder changed. {count} source files could not be removed.": {
323+
"one": "Složka inteligentních náhledů byla změněna. Neodstraněné zdrojové soubory: {count}.",
324+
"few": "Složka inteligentních náhledů byla změněna. Neodstraněné zdrojové soubory: {count}.",
325+
"many": "Složka inteligentních náhledů byla změněna. Neodstraněné zdrojové soubory: {count}.",
326+
"other": "Složka inteligentních náhledů byla změněna. Neodstraněné zdrojové soubory: {count}."
327+
}
299328
}

‎crates/ui-egui/locales/cs.json‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2063,5 +2063,31 @@
20632063
"Open Settings": "Otevřít nastavení",
20642064
"Select none": "Zrušit celý výběr",
20652065
"Select all": "Vybrat vše",
2066-
"Visualize HDR": "Zobrazit rozsah HDR"
2066+
"Visualize HDR": "Zobrazit rozsah HDR",
2067+
"About 39.5 MB per photo, measured on an A7CR proxy. Actual sizes vary; existing previews may reduce the space needed.": "Přibližně 39,5 MB na fotografii, měřeno na náhledu z A7CR. Skutečné velikosti se liší; existující náhledy mohou potřebné místo zmenšit.",
2068+
"Build": "Vytvořit",
2069+
"Build Anyway": "Přesto vytvořit",
2070+
"Build Lossless Smart Previews": "Vytvořit bezztrátové inteligentní náhledy",
2071+
"Build Smart Previews converts existing previews from available originals. Offline previews stay as they are until you build again with the drive connected.": "Vytvoření inteligentních náhledů převede existující náhledy z dostupných originálů. Náhledy nedostupných originálů zůstanou stejné, dokud je znovu nevytvoříte s připojeným diskem.",
2072+
"Build for All Photos": "Vytvořit pro všechny fotografie",
2073+
"Changing smart preview folder": "Změna složky inteligentních náhledů",
2074+
"Checking free space…": "Kontrola volného místa...",
2075+
"Compact (JPEG)": "Kompaktní (JPEG)",
2076+
"Compact uses about 1 MB per photo. Lossless preserves source precision and can use 40 to 50 MB per photo.": "Kompaktní náhledy používají asi 1 MB na fotografii. Bezztrátové zachovávají přesnost zdroje a mohou používat 40 až 50 MB na fotografii.",
2077+
"Format for new builds": "Formát pro nové náhledy",
2078+
"Free space is unavailable. Check the destination drive before building.": "Volné místo nelze zjistit. Před vytvořením náhledů zkontrolujte cílový disk.",
2079+
"Keep smart previews on a drive with enough free space. The thumbnail cache stays in the library.": "Inteligentní náhledy ukládejte na disk s dostatkem volného místa. Mezipaměť miniatur zůstane v knihovně.",
2080+
"Lossless (32-bit TIFF)": "Bezztrátový (32bitový TIFF)",
2081+
"Previews are rebuilt from available originals. Offline originals keep their existing previews.": "Náhledy se znovu vytvoří z dostupných originálů. Nedostupné originály si ponechají stávající náhledy.",
2082+
"Refreshing smart previews": "Obnova inteligentních náhledů",
2083+
"Smart Preview Format": "Formát inteligentních náhledů",
2084+
"Smart preview folder change cancelled. The old folder is still in use.": "Změna složky inteligentních náhledů byla zrušena. Nadále se používá původní složka.",
2085+
"Smart preview folder changed.": "Složka inteligentních náhledů byla změněna.",
2086+
"The estimated build will not fit in the available space. Free space or choose another folder before building.": "Odhadovaná velikost náhledů přesahuje volné místo. Před vytvořením uvolněte místo nebo zvolte jinou složku.",
2087+
"The old folder stays in use until copying finishes. Cancel keeps the old folder. Source cleanup cannot be cancelled after the folder changes.": "Původní složka se používá, dokud kopírování neskončí. Zrušení ponechá původní složku. Po změně složky již nelze zrušit odstranění zdrojových souborů.",
2088+
"Use Library Format": "Použít formát knihovny",
2089+
"no smart preview build to confirm": "žádné vytvoření inteligentních náhledů nečeká na potvrzení",
2090+
"the free-space check stopped unexpectedly": "kontrola volného místa se neočekávaně zastavila",
2091+
"the smart preview folder changed; start the build again to check its free space": "složka inteligentních náhledů se změnila; znovu spusťte vytvoření náhledů a zkontrolujte volné místo",
2092+
"wait for the free-space check to finish": "počkejte na dokončení kontroly volného místa"
20672093
}

‎crates/ui-egui/locales/it-formats.json‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
"the {n} selected photos": "le {n} foto selezionate",
136136
"the {} photos in view": "le {} foto nella vista",
137137
"these {count} photos": "queste {count} foto",
138-
"{count} smart preview{} · {:.1} MB": "Anteprime avanzate: {count}{0:.0} · {1:.1} MB",
139138
"{f} folders (and their subfolders)": "{f} cartelle (e le loro sottocartelle)",
140139
"{label} Grading": "Gradazione di {label}",
141140
"{label} {d:+} on every selected photo": "{label} {d:+} su ogni foto selezionata",
@@ -295,5 +294,35 @@
295294
"Already in “{}”": "Already in “{}”",
296295
"Move {n} photo{} to “{}”": "Move {n} photo{} to “{}”",
297296
"Move {n} photo{} to “{}”?": "Move {n} photo{} to “{}”?",
298-
"Moved {n} photo{} to “{}”. Edit → Undo moves them back.": "Moved {n} photo{} to “{}”. Edit → Undo moves them back."
297+
"Moved {n} photo{} to “{}”. Edit → Undo moves them back.": "Moved {n} photo{} to “{}”. Edit → Undo moves them back.",
298+
"Destination: {path}": "Destinazione: {path}",
299+
"Estimated total size: {size}": "Dimensioni totali stimate: {size}",
300+
"Free space: {size}": "Spazio libero: {size}",
301+
"Smart preview folder change failed: {error}": "Impossibile cambiare la cartella delle anteprime avanzate: {error}",
302+
"could not check smart preview storage: {e}": "impossibile verificare lo spazio per le anteprime avanzate: {e}",
303+
"free space is unavailable for {path} on this platform": "lo spazio libero per {path} non è disponibile su questa piattaforma",
304+
"Photos: {count}": {
305+
"one": "Foto: {count}",
306+
"few": "Foto: {count}",
307+
"many": "Foto: {count}",
308+
"other": "Foto: {count}"
309+
},
310+
"{count} smart previews · {size:.1} MiB": {
311+
"one": "Anteprime avanzate: {count} · {size:.1} MiB",
312+
"few": "Anteprime avanzate: {count} · {size:.1} MiB",
313+
"many": "Anteprime avanzate: {count} · {size:.1} MiB",
314+
"other": "Anteprime avanzate: {count} · {size:.1} MiB"
315+
},
316+
". {count} existing previews kept unchanged": {
317+
"one": ". Anteprime esistenti mantenute invariate: {count}",
318+
"few": ". Anteprime esistenti mantenute invariate: {count}",
319+
"many": ". Anteprime esistenti mantenute invariate: {count}",
320+
"other": ". Anteprime esistenti mantenute invariate: {count}"
321+
},
322+
"Smart preview folder changed. {count} source files could not be removed.": {
323+
"one": "La cartella delle anteprime avanzate è cambiata. File sorgente che non è stato possibile rimuovere: {count}.",
324+
"few": "La cartella delle anteprime avanzate è cambiata. File sorgente che non è stato possibile rimuovere: {count}.",
325+
"many": "La cartella delle anteprime avanzate è cambiata. File sorgente che non è stato possibile rimuovere: {count}.",
326+
"other": "La cartella delle anteprime avanzate è cambiata. File sorgente che non è stato possibile rimuovere: {count}."
327+
}
299328
}

‎crates/ui-egui/locales/it.json‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,5 +1990,31 @@
19901990
"Test Face Model": "Testa il modello dei volti",
19911991
"This build cannot run recognition models: they can be added and chosen, not used.": "Questa versione non può eseguire modelli di riconoscimento: si possono aggiungere e scegliere, non usare.",
19921992
"This build has nowhere to keep face models, so the model list is not available. (The desktop app has.)": "Questa versione non ha dove tenere i modelli dei volti, quindi l'elenco dei modelli non è disponibile. (L'app desktop ce l'ha.)",
1993-
"Unnamed Faces": "Volti senza nome"
1993+
"Unnamed Faces": "Volti senza nome",
1994+
"About 39.5 MB per photo, measured on an A7CR proxy. Actual sizes vary; existing previews may reduce the space needed.": "Circa 39,5 MB per foto, misurati su un'anteprima A7CR. Le dimensioni effettive variano; le anteprime esistenti possono ridurre lo spazio necessario.",
1995+
"Build": "Genera",
1996+
"Build Anyway": "Genera comunque",
1997+
"Build Lossless Smart Previews": "Genera anteprime avanzate senza perdita",
1998+
"Build Smart Previews converts existing previews from available originals. Offline previews stay as they are until you build again with the drive connected.": "Genera anteprime avanzate converte le anteprime esistenti dagli originali disponibili. Le anteprime degli originali non disponibili restano invariate finché non le generi di nuovo con il disco collegato.",
1999+
"Build for All Photos": "Genera per tutte le foto",
2000+
"Changing smart preview folder": "Cambio della cartella delle anteprime avanzate",
2001+
"Checking free space…": "Verifica dello spazio libero...",
2002+
"Compact (JPEG)": "Compatto (JPEG)",
2003+
"Compact uses about 1 MB per photo. Lossless preserves source precision and can use 40 to 50 MB per photo.": "Compatto usa circa 1 MB per foto. Senza perdita mantiene la precisione della sorgente e può usare da 40 a 50 MB per foto.",
2004+
"Format for new builds": "Formato per le nuove anteprime",
2005+
"Free space is unavailable. Check the destination drive before building.": "Lo spazio libero non è disponibile. Controlla il disco di destinazione prima di generare le anteprime.",
2006+
"Keep smart previews on a drive with enough free space. The thumbnail cache stays in the library.": "Tieni le anteprime avanzate su un disco con spazio libero sufficiente. La cache delle miniature resta nella libreria.",
2007+
"Lossless (32-bit TIFF)": "Senza perdita (TIFF a 32 bit)",
2008+
"Previews are rebuilt from available originals. Offline originals keep their existing previews.": "Le anteprime vengono rigenerate dagli originali disponibili. Gli originali non disponibili mantengono le anteprime esistenti.",
2009+
"Refreshing smart previews": "Aggiornamento delle anteprime avanzate",
2010+
"Smart Preview Format": "Formato delle anteprime avanzate",
2011+
"Smart preview folder change cancelled. The old folder is still in use.": "Il cambio della cartella delle anteprime avanzate è stato annullato. La cartella precedente è ancora in uso.",
2012+
"Smart preview folder changed.": "La cartella delle anteprime avanzate è cambiata.",
2013+
"The estimated build will not fit in the available space. Free space or choose another folder before building.": "Le dimensioni stimate superano lo spazio disponibile. Libera spazio o scegli un'altra cartella prima di generare le anteprime.",
2014+
"The old folder stays in use until copying finishes. Cancel keeps the old folder. Source cleanup cannot be cancelled after the folder changes.": "La cartella precedente resta in uso fino al termine della copia. Annulla mantiene la cartella precedente. La pulizia della sorgente non può essere annullata dopo il cambio della cartella.",
2015+
"Use Library Format": "Usa il formato della libreria",
2016+
"no smart preview build to confirm": "nessuna generazione di anteprime avanzate da confermare",
2017+
"the free-space check stopped unexpectedly": "la verifica dello spazio libero si è interrotta in modo imprevisto",
2018+
"the smart preview folder changed; start the build again to check its free space": "la cartella delle anteprime avanzate è cambiata; avvia di nuovo la generazione per verificarne lo spazio libero",
2019+
"wait for the free-space check to finish": "attendi il termine della verifica dello spazio libero"
19942020
}

0 commit comments

Comments
 (0)