Skip to content

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

Merge main into fix/local-record-eviction

Brandon Thomas1f2f25356a0e
diff --cc crates/engine/src/cmd/library.rs
index a8123dcb1,aafff8266..35a477470
--- a/crates/engine/src/cmd/library.rs
+++ b/crates/engine/src/cmd/library.rs
@@@ -867,8 -867,9 +867,11 @@@ pub fn specs() -> Vec<CommandSpec>
"logRecords": j.log_records(),
"logBytes": j.log_bytes(),
"lastError": lib.last_error,
+ // changes applied in memory whose write failed (retried by every save)
+ "unsavedOps": s.unsaved().map_or(0, |u| u.0),
+ "unsavedError": s.unsaved().map(|u| u.1),
+ // untouched Local records forgotten when the library opened
+ "forgotLocal": lib.forgot_local.as_ref().map(|p| json!({"forgotten": p.evict.len(), "local": p.local, "keptRecent": p.kept_recent, "keptTouched": p.kept_touched, "keptInUse": p.kept_in_use})),
"persistence": j.stats(),
"cache": cache,
"load": {
diff --cc crates/engine/src/library.rs
index a89cab272,54400764c..6fcb08d28
--- a/crates/engine/src/library.rs
+++ b/crates/engine/src/library.rs
@@@ -52,8 -55,11 +55,13 @@@ pub struct Library
pub report: LoadReport,
/// Last persistence error (shown by the UI; ops stay pending and are retried).
pub last_error: Option<String>,
+ /// Why the last append of queued ops failed; `None` once a save succeeds. While set, changes
+ /// exist only in memory ([`Session::unsaved`]).
+ pub unsaved_error: Option<String>,
+ /// When the frame loop may retry a failed append ([`Session::persist_if_dirty`] backs off).
+ retry_at: Option<web_time::Instant>,
+ /// What forgetting untouched Local records did when the library opened.
+ pub forgot_local: Option<lightcraft_catalog::ForgetPlan>,
presets_written: String,
view_written: Vec<u8>,
}
@@@ -254,23 -259,19 +265,35 @@@ impl Session
self.media.attach_disk_cache(&dir.join("thumbs"), self.cache_bytes());
}
let view_written = self.view_json();
- self.library = Some(Library { dir, on_disk, journal, files, report, last_error: None, forgot_local: None, presets_written, view_written });
- let library = self.library.insert(Library {
++ self.library = Some(Library {
+ dir,
+ on_disk,
+ journal,
+ files,
+ report,
+ last_error: None,
+ unsaved_error: None,
+ retry_at: None,
++ forgot_local: None,
+ presets_written,
+ view_written,
+ });
- Ok(&library.report)
+ // forget untouched Local records of folders not browsed for a while (journaled at once)
+ if self.forget_local_days > 0 {
+ let plan = self.forget_local(false, None);
+ if !plan.evict.is_empty() {
+ self.compact_soon();
+ } else if let Err(e) = self.persist() {
+ log::error!("library: {e}");
+ }
+ if let Some(lib) = self.library.as_mut() {
+ lib.forgot_local = Some(plan);
+ }
+ }
+ match &self.library {
+ Some(lib) => Ok(&lib.report),
+ None => Err(EngineError::Other("library closed while opening".into())),
+ }
}
/// Write pending ops to the log (fsynced), compact when due, and save changed presets.
diff --cc docs/whats-new.md
index 7871f6c22,19b286290..1ebec435b
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -21,9 -21,9 +21,12 @@@
- Export file names use the Rename Photos tokens ({title}, {seq:2}, {date:%Y-%m-%d}…), plus new {num}, {folder}, {lens}, {iso}, {rating}, {creator}.
- Copyright status, rights usage terms and copyright info URL in Info, metadata presets and exports.
- Auto-Tag from Tracklog: GPS locations for your photos from a GPX track log, matched by capture time.
+ - A change that can't be saved to disk (full or unplugged drive) is no longer silent: the command reports
+ "saved in memory but not written to disk", the top bar shows a warning, and LightCraft keeps retrying until the
+ save goes through.
+- Smaller, faster catalogs: photos you only looked at in Local (never added, rated or edited) are forgotten once
+ their folder has not been browsed for 30 days — your files and sidecars stay, and browsing the folder shows them
+ again. Change the period (or turn it off) in Settings → Performance.
### Editing
- Auto Sync: edits apply to every selected photo. Auto B&W mix. Automatic versions.