From 6735b23e5bd3257c1c36d48f4068b991a3c24556 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 22 Mar 2022 13:09:19 +1000 Subject: [PATCH] Force a schema change on colpkg import If we don't force a full sync when restoring, any items that were added since the backup may have already been sent to AnkiWeb, and they won't have deletion records. After the user restores from a backup, they'll end up in a state where their local and AnkiWeb collections differ, and the changes will not sync. The old backup code forced a schema change, but we weren't previously doing it via File>Import. --- rslib/src/import_export/package/colpkg/import.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rslib/src/import_export/package/colpkg/import.rs b/rslib/src/import_export/package/colpkg/import.rs index 441aa4a2d..7664637a4 100644 --- a/rslib/src/import_export/package/colpkg/import.rs +++ b/rslib/src/import_export/package/colpkg/import.rs @@ -69,7 +69,7 @@ pub fn import_colpkg( copy_collection(&mut archive, &mut tempfile, &meta)?; progress_fn(ImportProgress::Collection)?; - check_collection(tempfile.path())?; + check_collection_and_mod_schema(tempfile.path())?; progress_fn(ImportProgress::Collection)?; let media_folder = Path::new(target_media_folder); @@ -78,11 +78,12 @@ pub fn import_colpkg( atomic_rename(tempfile, &col_path, true) } -fn check_collection(col_path: &Path) -> Result<()> { +fn check_collection_and_mod_schema(col_path: &Path) -> Result<()> { CollectionBuilder::new(col_path) .build() .ok() - .and_then(|col| { + .and_then(|mut col| { + col.set_schema_modified().ok()?; col.storage .db .pragma_query_value(None, "integrity_check", |row| row.get::<_, String>(0))