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:
@@ -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.",
|
||||
|
||||
Reference in New Issue
Block a user