mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
do integrity check when closing collection
This commit is contained in:
parent
e48a9f998b
commit
4bfbd2396a
1 changed files with 10 additions and 3 deletions
13
aqt/main.py
13
aqt/main.py
|
@ -269,10 +269,17 @@ how to restore from a backup.""")
|
||||||
if not self.closeAllCollectionWindows():
|
if not self.closeAllCollectionWindows():
|
||||||
return
|
return
|
||||||
self.maybeOptimize()
|
self.maybeOptimize()
|
||||||
|
self.progress.start(immediate=True)
|
||||||
|
corrupt = self.col.db.scalar("pragma integrity_check") != "ok"
|
||||||
|
if corrupt:
|
||||||
|
showWarning(_("Your collection file appears to be corrupt. \
|
||||||
|
This can happen when the file is copied or moved while Anki is open, or \
|
||||||
|
when the collection is stored on a network or cloud drive. Please see \
|
||||||
|
the manual for information on how to restore from an automatic backup."))
|
||||||
self.col.close()
|
self.col.close()
|
||||||
self.col = None
|
self.col = None
|
||||||
self.progress.start(immediate=True)
|
if not corrupt:
|
||||||
self.backup()
|
self.backup()
|
||||||
self.progress.finish()
|
self.progress.finish()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -314,7 +321,7 @@ how to restore from a backup.""")
|
||||||
os.unlink(os.path.join(dir, file[1]))
|
os.unlink(os.path.join(dir, file[1]))
|
||||||
|
|
||||||
def maybeOptimize(self):
|
def maybeOptimize(self):
|
||||||
# has two weeks passed?
|
# have two weeks passed?
|
||||||
if (intTime() - self.pm.profile['lastOptimize']) < 86400*14:
|
if (intTime() - self.pm.profile['lastOptimize']) < 86400*14:
|
||||||
return
|
return
|
||||||
self.progress.start(label=_("Optimizing..."), immediate=True)
|
self.progress.start(label=_("Optimizing..."), immediate=True)
|
||||||
|
|
Loading…
Reference in a new issue