Skip to content

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

Merge PR #1809: engine: keep the decoder facts a smart preview's offline edits need

aionggbf2f3df0ac88
diff --cc crates/engine/src/cmd/previews.rs
index 0d8999989,a3b56dee0..093a4676e
--- a/crates/engine/src/cmd/previews.rs
+++ b/crates/engine/src/cmd/previews.rs
@@@ -176,8 -176,9 +176,9 @@@ fn build(s: &mut Session, p: &Value) -
}
/// One photo's smart preview to build or discard: (photo, its file in the smart previews folder,
-/// how to load the original at preview size, whether the photo takes the per-file camera look —
-/// `camera_preview::file_local_look`, [`lightcraft_catalog::Photo::fitted_look`]: only those
-/// proxies go stale when the fit changes; an older encoding makes any proxy stale).
+/// how to load the original at preview size, whether the photo can take a preview-fitted look:
- /// vendor raws and DNGs (whose tone can come from their preview).
++/// vendor raws and DNGs (whose tone can come from their preview); only those proxies go stale when
++/// the fit changes; an older encoding makes any proxy stale).
#[cfg(not(target_arch = "wasm32"))]
type SmartJob = (lightcraft_catalog::PhotoId, std::path::PathBuf, Option<crate::media::SourceRef>, bool);
@@@ -365,14 -365,14 +371,14 @@@ fn smart(s: &mut Session, p: &Value) -
)
}
- /// Bring smart previews written by an older camera-look fit up to date, once per fit version: when
- /// the smart previews folder has not been checked at this `LOOK_VERSION` (its marker,
- /// [`crate::smart::look_checked`]), a worker thread (the UI never waits on the drives) looks at the
- /// proxies of the raws that take the per-file camera look, the only ones the fit reaches (JPEG,
- /// PNG… proxies are never rebuilt), and rebuilds the stale ones from their originals. One whose
- /// original can't be read (offline) is kept as it is, still marked stale in its header: Build
- /// Smart Previews rebuilds it once the original is back. Only existing proxies are touched: none
- /// is built, and a missing folder is never created. Returns the thread, if started.
+ /// Bring smart previews up to date, once per fit-and-encoding version: when the smart previews
+ /// folder has not been checked at this build's versions (its marker, [`crate::smart::look_checked`]),
+ /// a worker thread (the UI never waits on the drives) looks at the proxies of the photos on disk
+ /// and rebuilds the stale ones from their originals — one whose stored pixels are an older encoding
-/// (every photo), or, for a raw that takes the per-file camera look, one written by an older fit.
++/// (every photo), or, for a raw that takes the per-file camera look or a DNG, one written by an older fit.
+ /// One whose original can't be read (offline) is kept as it is, still marked stale in its header:
+ /// Build Smart Previews rebuilds it once the original is back. Only existing proxies are touched:
+ /// none is built, and a missing folder is never created. Returns the thread, if started.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn refresh_stale_smart_previews(s: &mut Session) -> Option<std::thread::JoinHandle<()>> {
let dir = s.media.smart_dir.clone()?;
@@@ -380,10 -380,11 +386,11 @@@
return None;
}
let max_edge = crate::media::SourceLevel::Preview.max_edge();
- let photos: Vec<_> =
- s.catalog.photos().filter(|p| matches!(p.source, lightcraft_catalog::Source::File { .. }) && preview_fitted_look(p)).collect();
- let jobs: Vec<SmartJob> =
- photos.iter().map(|p| (p.id, crate::smart::sharded_file_path(&dir, p), Some(s.media.origin_ref(&p.source, max_edge)), true)).collect();
+ let photos: Vec<_> = s.catalog.photos().filter(|p| matches!(p.source, lightcraft_catalog::Source::File { .. })).collect();
+ let jobs: Vec<SmartJob> = photos
+ .iter()
- .map(|p| (p.id, crate::smart::sharded_file_path(&dir, p), Some(s.media.origin_ref(&p.source, max_edge)), p.fitted_look()))
++ .map(|p| (p.id, crate::smart::sharded_file_path(&dir, p), Some(s.media.origin_ref(&p.source, max_edge)), preview_fitted_look(p)))
+ .collect();
std::thread::Builder::new()
.name("lc-smart-look".into())
.spawn(move || refresh_stale(&dir, jobs))