Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 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
8332b4d
Catalog: restore a library from a backup, and keep what it replaces
nledford Oct 10, 2026
1832d7a
Catalog: say what a restore does with the files an upgrade kept
nledford Oct 11, 2026
8917bee
Catalog: review fixes for restore: a backup named by its files is ref…
nledford Oct 18, 2026
04f2cd4
Catalog: the backup tests remove the folders they restore into
nledford Oct 18, 2026
e2e4159
Locales: fi, id, sv and vi for the restore labels; Parity: summary re…
nledford Oct 22, 2026
5f864f6
Catalog: restore from the File menu, with the backup copied in the ba…
nledford Oct 11, 2026
315eca7
Catalog: review fixes for the restore in the background: a given-up w…
nledford Oct 18, 2026
122fcb6
Catalog: review fixes for the restore in the background: a late worke…
nledford Oct 18, 2026
a2691bd
Catalog: a restore's status stays running while its worker still clea…
nledford Oct 18, 2026
59452ba
Locales: fi, id, sv and vi for the background restore; Parity: summar…
nledford Oct 22, 2026
9820b0f
Catalog: the menus list one Restore Library from Backup… per host, th…
nledford Oct 30, 2026
68a3c56
Catalog: the backup folder is shown and chosen in Settings
nledford Oct 11, 2026
58e80fe
Catalog: Settings reads the backup folder without running a command, …
nledford Oct 11, 2026
ca3523c
Catalog: the rule for where backups go can't be walked round
nledford Oct 11, 2026
14b324b
Catalog: What's New says Back Up Library goes to the library's backup…
nledford Oct 18, 2026
7fdc8c0
Catalog: a backup folder that could not be saved is not chosen, and W…
nledford Oct 18, 2026
3fb84f4
Catalog: the usual Backups folder is told by its real path
nledford Oct 18, 2026
656f855
Locales: fi, id, sv and vi for the backup folder; de in du; Parity: s…
nledford Oct 22, 2026
1a5f2f9
Settings: Backups ▸ Folder is one line cut from the front like the ot…
nledford Oct 30, 2026
36ac223
Catalog: a library is backed up by itself while it is open, and when …
nledford Oct 11, 2026
ba753e6
Catalog: quitting with a backup ahead can always be finished, and wai…
nledford Oct 11, 2026
e3d59c9
Catalog: only the open library's own backup is waited for at quitting…
nledford Oct 11, 2026
997c2bb
Catalog: review fixes for backup by itself: a changed folder, and a s…
nledford Oct 18, 2026
2b568f8
Catalog: review fixes for backup by itself: the tests that hold a bac…
nledford Oct 18, 2026
29b941c
Catalog: review fixes for backup by itself: a key bound to Back Up Li…
nledford Oct 18, 2026
d457390
Catalog: review fixes for backup by itself: the key test has no unuse…
nledford Oct 18, 2026
faeb847
Catalog: the schedule tests' scratch folder is removed by a guard, al…
nledford Oct 18, 2026
eabb210
Locales: fi, id, sv and vi for the backup schedule; Parity: summary r…
nledford Oct 22, 2026
85d46b3
Catalog: a library can keep its backups for a time, and old ones go a…
nledford Oct 11, 2026
a0b2ba9
Catalog: a backup that a file manager wrote into is removed like any …
nledford Oct 18, 2026
d65944a
Catalog: the backup preferences compile where they were merged (befor…
nledford Oct 18, 2026
ad04589
Catalog: a restore into another folder forgets the library id while i…
nledford Oct 18, 2026
3d6521d
Catalog: forgetting the library id rewrites prefs.json durably
nledford Oct 18, 2026
6e5f147
Locales: fi, id, sv and vi for backup pruning; Parity: summary refreshed
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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