mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
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
1 changed files with 4 additions and 3 deletions
|
@ -69,7 +69,7 @@ pub fn import_colpkg(
|
||||||
|
|
||||||
copy_collection(&mut archive, &mut tempfile, &meta)?;
|
copy_collection(&mut archive, &mut tempfile, &meta)?;
|
||||||
progress_fn(ImportProgress::Collection)?;
|
progress_fn(ImportProgress::Collection)?;
|
||||||
check_collection(tempfile.path())?;
|
check_collection_and_mod_schema(tempfile.path())?;
|
||||||
progress_fn(ImportProgress::Collection)?;
|
progress_fn(ImportProgress::Collection)?;
|
||||||
|
|
||||||
let media_folder = Path::new(target_media_folder);
|
let media_folder = Path::new(target_media_folder);
|
||||||
|
@ -78,11 +78,12 @@ pub fn import_colpkg(
|
||||||
atomic_rename(tempfile, &col_path, true)
|
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)
|
CollectionBuilder::new(col_path)
|
||||||
.build()
|
.build()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|col| {
|
.and_then(|mut col| {
|
||||||
|
col.set_schema_modified().ok()?;
|
||||||
col.storage
|
col.storage
|
||||||
.db
|
.db
|
||||||
.pragma_query_value(None, "integrity_check", |row| row.get::<_, String>(0))
|
.pragma_query_value(None, "integrity_check", |row| row.get::<_, String>(0))
|
||||||
|
|
Loading…
Reference in a new issue