Skip to content

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

fix: scope relative-date expiry to referenced albums

ronibalthazar522ae832ec06
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index 4ea007b30..b40be289f 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -200,10 +200,24 @@ fn clock_minute(now: &str) -> &str {
now.get(..16).unwrap_or(now)
}
-/// Whether a query can change membership without a catalog edit, including smart albums it tests.
+/// Whether a query can change membership without a catalog edit, including the smart albums it tests.
fn filter_depends_on_clock(filter: &Filter, catalog: &Catalog) -> bool {
- filter.depends_on_now()
- || (!filter.albums_tested().is_empty() && catalog.albums().any(|album| album.smart.as_deref().is_some_and(Filter::depends_on_now)))
+ if filter.depends_on_now() {
+ return true;
+ }
+ let mut pending = filter.albums_tested();
+ let mut seen = std::collections::HashSet::new();
+ while let Some(id) = pending.pop() {
+ if !seen.insert(id) {
+ continue;
+ }
+ let Some(smart) = catalog.album(id).and_then(|album| album.smart.as_deref()) else { continue };
+ if smart.depends_on_now() {
+ return true;
+ }
+ pending.extend(smart.albums_tested());
+ }
+ false
}
/// Source of [`Session::visible_shared`] generations (process-wide, so two sessions never share one).
diff --git a/crates/engine/src/tests_view_follow.rs b/crates/engine/src/tests_view_follow.rs
index bdfa21c70..bc47d94c9 100644
--- a/crates/engine/src/tests_view_follow.rs
+++ b/crates/engine/src/tests_view_follow.rs
@@ -1,7 +1,7 @@
//! The view follows a small edit from the list it had ([`Session::visible`]): whatever the edit, the result has to
//! be the list worked out from every photo.
-use lightcraft_catalog::{Op, Photo, PhotoId, Source};
+use lightcraft_catalog::{Album, Op, Photo, PhotoId, Source};
use serde_json::{Value, json};
use crate::Session;
@@ -279,6 +279,28 @@ fn relative_clock_absolute_and_same_minute_views_keep_their_generations() {
assert_eq!(same_minute_ids, relative_ids);
}
+#[test]
+fn relative_clock_unrelated_smart_album_does_not_expire_album_filter_view() {
+ let (mut s, now, ids) = relative_clock_session(&["2026-10-23T12:00:30"]);
+ let manual = s.catalog.alloc_album_id();
+ s.catalog.apply(Op::AddAlbum { album: Album::new(manual, "Manual") }).unwrap();
+ s.catalog.apply(Op::SetAlbumPhotos { id: manual, photos: vec![ids[0]] }).unwrap();
+ s.execute(
+ "album.createSmart",
+ &json!({"name": "Unrelated recent", "rules": {"ruleSet": {"rules": [{"field": "captureDate", "op": "inLast", "value": 1}]}}}),
+ )
+ .unwrap();
+ s.execute("library.filter", &json!({"ruleSet": {"rules": [{"field": "album", "op": "is", "value": manual.0}]}})).unwrap();
+ let (generation, visible) = s.visible_shared();
+ assert_eq!(visible.as_ref(), ids.as_slice());
+
+ *now.lock().unwrap() = "2026-10-24T12:01:00".to_string();
+ let (after_generation, after_visible) = s.visible_shared();
+
+ assert_eq!(after_generation, generation, "an unrelated relative smart album must not expire this view");
+ assert_eq!(after_visible, visible);
+}
+
#[test]
fn a_view_that_asks_about_the_last_days_follows_the_clock_too() {
let (mut s, ids, _, _) = library(60);
diff --git a/docs/gaps.md b/docs/gaps.md
index fce7910e7..daa9f391e 100644
--- a/docs/gaps.md
+++ b/docs/gaps.md
@@ -83,8 +83,8 @@ Beta-blocking gaps (B) total **~230–430 h**; with the stability and platform w
## Revision history
| Date | Change | Summary |
-| 2026-10-24 | minor | LR-LIB-SMARTALBUM: relative-date views and source totals expire on the session-clock minute, including nested smart albums; ranked gaps and readiness counts unchanged |
|---|---|---|
+| 2026-10-24 | minor | LR-LIB-SMARTALBUM: relative-date views and source totals expire on the session-clock minute, including nested smart albums; ranked gaps and readiness counts unchanged |
| 2026-10-22 | patch | XMP namespace-prefix collisions no longer overwrite foreign metadata; ranked gaps and estimates unchanged |
| 2026-10-22 | patch | Issue #2519: PSD/PSB EXIF resource 1058 and XMP resource 1060 now use the common metadata extractor, and `.psb` files are accepted by import; no ranked gap or readiness count changes |
| 2026-10-22 | minor | Gap 30 added: multi-select metadata editing — Info panel and All Metadata dialog show one photo's values with no mixed-value indication |
diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md
index be358c486..9444247ca 100644
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@ -797,8 +797,8 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
## Revision history
| Date | Change | Summary |
-| 2026-10-24 | patch | LR-LIB-SMARTALBUM: relative-date view and source-count caches expire on the session-clock minute, including nested smart albums; held views retain expired photos until refresh and admit new matches; status and feature counts unchanged |
|---|---|---|
+| 2026-10-24 | patch | LR-LIB-SMARTALBUM: relative-date view and source-count caches expire on the session-clock minute, including nested smart albums; held views retain expired photos until refresh and admit new matches; status and feature counts unchanged |
| 2026-10-22 | patch | LR-META-XMP: namespace URI determines ownership; foreign namespaces using recognized prefixes survive saves and cannot supply native settings or ratings; status and counts unchanged |
| 2026-10-22 | patch | LR-EXP-PSD, LR-META-EXIF-FULL: PSD/PSB imports and image resources 1058/1060 now supply EXIF and XMP to metadata readers and All Metadata; Original with Remove Location Info refuses detected PSD/PSB GPS; statuses and feature counts unchanged |
| 2026-10-21 | patch | LR-IMP-ADD-DIALOG: reconcile #2362 with current main; deleted-album guard and hierarchical picker retained; counts unchanged |