force full sync when restoring from backup

This commit is contained in:
Damien Elmes 2012-12-22 08:34:11 +09:00
parent b5c6a77c9f
commit 73f8d1a457

View file

@ -325,6 +325,7 @@ def setupApkgImport(mw, importer):
if not full: if not full:
# adding # adding
return True return True
backup = re.match("backup-.*\\.apkg", base)
if not askUser(_("""\ if not askUser(_("""\
This will delete your existing collection and replace it with the data in \ This will delete your existing collection and replace it with the data in \
the file you're importing. Are you sure?"""), msgfunc=QMessageBox.warning): the file you're importing. Are you sure?"""), msgfunc=QMessageBox.warning):
@ -333,9 +334,9 @@ the file you're importing. Are you sure?"""), msgfunc=QMessageBox.warning):
# called as part of the startup routine # called as part of the startup routine
mw.progress.start(immediate=True) mw.progress.start(immediate=True)
mw.progress.timer( mw.progress.timer(
100, lambda mw=mw, f=importer.file: replaceWithApkg(mw, f), False) 100, lambda mw=mw, f=importer.file: replaceWithApkg(mw, f, backup), False)
def replaceWithApkg(mw, file): def replaceWithApkg(mw, file, backup):
# unload collection, which will also trigger a backup # unload collection, which will also trigger a backup
mw.unloadCollection() mw.unloadCollection()
# overwrite collection # overwrite collection
@ -351,4 +352,6 @@ def replaceWithApkg(mw, file):
z.close() z.close()
# reload # reload
mw.loadCollection() mw.loadCollection()
if backup:
mw.col.modSchema(check=False)
mw.progress.finish() mw.progress.finish()