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.
This commit is contained in:
parent
44342660d8
commit
6735b23e5b
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user