Card data update: release reference.db before replacing it

Windows refuses to replace a file SQLite has open, so every update after the first failed at the final swap with "Access is denied". Building and installing are now separate: the app stays usable during the build, then closes the catalog, swaps the file and reopens under the state lock. The swap retries briefly in case a virus scanner is holding the new file, and a failed one puts the previous data back in service and removes the temp file. Importing a card database shares the same swap.
This commit is contained in:
2026-10-30 20:15:34 -05:00
parent 70c89a5644
commit c527e5d6f7
4 changed files with 144 additions and 36 deletions

View File

@@ -15,9 +15,14 @@ fn main() -> ExitCode {
eprintln!("Building reference db at {}", dest.display());
let cancel = CancelToken::new();
match mtgc_core::ingest::build_reference_db(&dest, &cancel, |p| {
let built = mtgc_core::ingest::build_reference_db(&dest, &cancel, |p| {
eprintln!(" [{}] {:.1}% {}", p.stage, p.overall_percent, p.message)
}) {
})
.and_then(|(tmp, stats)| {
mtgc_core::ingest::install_reference_db(&tmp, &dest)?;
Ok(stats)
});
match built {
Ok(stats) => {
eprintln!(
"Done: {} oracle cards, {} printings.",