DictionaryDB: use backup on load from file, if available

This commit is contained in:
Doug Blank 2016-04-15 09:45:41 -04:00
parent ce33e7509c
commit 684788f2fd

View File

@ -28,6 +28,8 @@ from gramps.gen.db.generic import *
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
import glob
class DictionaryDb(DbGeneric): class DictionaryDb(DbGeneric):
""" """
Database backend class for dictionary databases Database backend class for dictionary databases
@ -1066,8 +1068,11 @@ class DictionaryDb(DbGeneric):
from gramps.plugins.importer.importxml import importData from gramps.plugins.importer.importxml import importData
from gramps.cli.user import User from gramps.cli.user import User
if self._directory: if self._directory:
filename = os.path.join(self._directory, "data.gramps") backups = list(reversed(glob.glob(os.path.join(
if os.path.isfile(filename): self._directory, "backup-*.gramps"))))
importData(self, filename, User()) if backups:
self.reindex_reference_map(lambda progress: None) filename = backups[0]
self.rebuild_secondary(lambda progress: None) if os.path.isfile(filename):
importData(self, filename, User())
self.reindex_reference_map(lambda progress: None)
self.rebuild_secondary(lambda progress: None)