Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cb38a07
Catalog: an upgrade keeps the files it replaces
nledford Oct 23, 2026
1ec43ee
Catalog: a later upgrade tells where it kept the files it replaced
nledford Oct 26, 2026
26cf95d
Catalog: a snapshot already in this format is the upgrade done, and t…
nledford Oct 26, 2026
d50ad6f
Catalog: a write that fails leaves no staging file, so a copy that ca…
nledford Oct 26, 2026
c8be9db
Catalog: the docs and comments say what a failed later snapshot leave…
nledford Oct 29, 2026
af6b1c5
Catalog: the damaged-log bullet and the module docs say what is left …
nledford Oct 29, 2026
f9e8358
Upgrade notice names a damaged log kept by the upgrade; the way back …
nledford Oct 29, 2026
c6f52eb
Catalog: the store can write files that a later write names, list its…
nledford Oct 23, 2026
c08a818
Catalog: a library states what its missing develop settings read as
nledford Oct 23, 2026
3cdf821
Catalog: say what the next open reads after a rewrite for other defau…
nledford Oct 25, 2026
9fc9453
Catalog: the test for the defaults reading ending with the open leave…
nledford Oct 30, 2026
4decee3
Catalog: the formats are one table, and every format from 6 on has a …
nledford Oct 25, 2026
a340c33
Catalog: develop settings can be stored as their difference from the …
nledford Oct 25, 2026
254e30e
catalog: read, append and truncate refuse a segments folder that isn'…
nledford Oct 25, 2026
2a51d02
Catalog: compact records are format 10
nledford Oct 25, 2026
b9fa882
Merge catalog-store-hooks (#2871, 254e30e4cf) into the catalog compac…
nledford Oct 30, 2026
50b6190
Catalog: the segments of a snapshot: their names, rules, writer and r…
nledford Oct 23, 2026
852b8fa
Catalog: the journal saves the snapshot in segments and opens one (fo…
nledford Oct 25, 2026
9e9e84c
Catalog: map the v10 catalog fixtures in ci_quick::EMBEDDED
nledford Oct 26, 2026
d88a313
Catalog: the put-off upgrade's tests, from #2958, run on format 11's …
nledford Oct 26, 2026
038f346
Catalog: segment files nothing lists are removed when the library is …
nledford Oct 25, 2026
870cdea
Catalog: a compaction writes only the segments whose photos changed
nledford Oct 25, 2026
f381d2e
Catalog: back up the library to a dated folder that shares unchanged …
nledford Oct 10, 2026
c2bde11
Catalog: the library's own files are one list, and backups take all o…
nledford Oct 11, 2026
fdb46e3
Catalog: a backup ignores what the OS writes into its folder, and a m…
nledford Oct 18, 2026
5e38caf
Catalog: sweep takes only a missing segments folder for quiet, and th…
nledford Oct 18, 2026
b98cb85
Catalog: the sweep test that sets folder times is for Unix
nledford Oct 18, 2026
3dd8fc4
Locales: fi, id, sv and vi for the backup labels; Parity: summary ref…
nledford Oct 22, 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
19 changes: 17 additions & 2 deletions apps/lightcraft-web/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::io;
use std::sync::{Arc, Mutex};

use lightcraft_engine::catalog::Store;
use lightcraft_engine::library::SettingsFile;

/// What has to be written for a dirty file.
#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -190,13 +191,19 @@ impl Store for FilesStore {
self.0.truncate(name, len as usize);
Ok(())
}
/// The browser always runs the newest build, and its storage is small.
fn keeps_replaced_formats(&self) -> bool {
false
}
fn describe(&self) -> String {
"browser storage".into()
}
}

/// Names of the library files read at start-up.
pub const LIBRARY_FILES: [&str; 6] = ["catalog.snap", "catalog.log", "presets.json", "view.json", "prefs.json", "ui.json"];
/// Names of the library files read at start-up: the catalog, the library's own files (every one
/// of `SettingsFile::ALL`; a test holds that), and the interface's.
pub const LIBRARY_FILES: [&str; 6] =
["catalog.snap", "catalog.log", SettingsFile::Presets.name(), SettingsFile::View.name(), SettingsFile::Prefs.name(), "ui.json"];

/// Is a browser storage error, by its `DOMException` name, "the entry doesn't exist"? Only
/// `NotFoundError` is; anything else (security, type mismatch, an unreadable store) is a failure.
Expand Down Expand Up @@ -226,6 +233,14 @@ mod tests {
use lightcraft_engine::library::LibraryStores;
use serde_json::json;

/// Every file the library has is read at start-up (and so saved and backed up by the page).
#[test]
fn every_file_of_the_library_is_read_at_start_up() {
for file in SettingsFile::ALL {
assert!(LIBRARY_FILES.contains(&file.name()), "{}", file.name());
}
}

/// Apply flush ops to a "disk" map, as the backend would.
fn flush(files: &Files, disk: &mut BTreeMap<String, Vec<u8>>) {
for op in files.take_dirty() {
Expand Down
27 changes: 23 additions & 4 deletions crates/catalog/examples/persist_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
j.append(&ops)?;
}
j.snapshot(&cat)?;
let first = j.stats().last_snapshot;
println!("== {n} photos ({} local): snapshot {:.1} MB", cat.photos().filter(|p| p.local).count(), first.bytes as f64 / 1e6);
println!("== {n} photos ({} local): snapshot {:.1} MB", cat.photos().filter(|p| p.local).count(), j.snapshot_bytes() as f64 / 1e6);

let t = Instant::now();
let copy = cat.clone();
Expand Down Expand Up @@ -158,6 +157,26 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
}
println!(" background compaction blocking: {}", stats(blocking));

// changes all over the library (a rating on every 50th photo), then one compaction
let spread: Vec<PhotoId> = cat.photos().map(|p| p.id).step_by(50).collect();
let ops: Vec<Op> = spread.iter().map(|id| Op::SetRating { id: *id, rating: 3 }).collect();
for op in &ops {
cat.apply(op.clone())?;
}
j.append(&ops)?;
j.snapshot(&cat)?;
let s = j.stats().last_snapshot;
println!(" compaction after {} changes all over the library: wrote {:.1} MB in {:.1} ms", ops.len(), s.bytes as f64 / 1e6, s.total_ms);
// and after changes in one place (the first 1000 photos)
let ops: Vec<Op> = ids.iter().map(|id| Op::SetRating { id: *id, rating: 4 }).collect();
for op in &ops {
cat.apply(op.clone())?;
}
j.append(&ops)?;
j.snapshot(&cat)?;
let s = j.stats().last_snapshot;
println!(" compaction after {} changes in one place: wrote {:.1} MB in {:.1} ms", ops.len(), s.bytes as f64 / 1e6, s.total_ms);

// forget the untouched Local records (folders last browsed long ago; every 7th folder
// recently; every 50th Local record rated), then compact
let folders: std::collections::BTreeSet<String> = cat.photos().filter(|p| p.local).filter_map(|p| folder_of(p)).collect();
Expand All @@ -175,7 +194,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
}
j.append(&ops)?;
j.snapshot(&cat)?;
let before = j.stats().last_snapshot.bytes;
let before = j.snapshot_bytes();
let t = Instant::now();
let plan = cat.forget_local_plan("2026-10-05T00:00:00", DEFAULT_FORGET_DAYS, &|_| false);
let plan_ms = ms(t);
Expand All @@ -187,7 +206,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
j.append(&ops)?;
let apply_ms = ms(t);
j.snapshot(&cat)?;
let after = j.stats().last_snapshot.bytes;
let after = j.snapshot_bytes();
println!(
" forget Local: {} of {} local records forgotten (kept: {} recent, {} touched, {} in use); plan {plan_ms:.1} ms, apply+append {apply_ms:.1} ms; snapshot {:.1} MB -> {:.1} MB",
plan.evict.len(),
Expand Down
7 changes: 7 additions & 0 deletions crates/catalog/proptest-regressions/tests_segments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc 9f973b20fb5e7757eb3527f1d0e006379629e5bc8fb2b60cd1d5003295f9eeaf # shrinks to per = 1, steps = [(0, 0, 1), (5, 0, 1)]
Loading
Loading