0006529: Cancelling database upgrade can corrupt the database. Check whether the bsddb version has changed (or was originally unknown). If it is an upgrade, ask the user whether he has made a backup, and is ready to upgrade. If so, made a zip backup and open the database with the new bsddb version. Make messages on the dialogues more explicit with the version numbers mentioned.
svn: r21850
This commit is contained in:
@@ -370,12 +370,8 @@ class ArgHandler(object):
|
||||
if not self.check_db(db_path, self.force_unlock):
|
||||
sys.exit(0)
|
||||
# Add the file to the recent items
|
||||
path = os.path.join(db_path, "name.txt")
|
||||
try:
|
||||
ifile = open(path)
|
||||
title = ifile.readline().strip()
|
||||
ifile.close()
|
||||
except:
|
||||
title = self.dbstate.db.get_dbname()
|
||||
if not title:
|
||||
title = db_path
|
||||
RecentFiles.recent_files(db_path, title)
|
||||
self.open = db_path
|
||||
|
||||
@@ -46,6 +46,8 @@ from gen.ggettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".clidbman")
|
||||
from gen.db.dbconst import DBLOGNAME
|
||||
_LOG = logging.getLogger(DBLOGNAME)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -345,6 +347,11 @@ class CLIDbManager(object):
|
||||
self.__start_cursor(_("Importing data..."))
|
||||
dbclass = gen.db.DbBsddb
|
||||
dbase = dbclass()
|
||||
from gen.db.dbconst import BDBVERSFN
|
||||
versionpath = os.path.join(name, BDBVERSFN)
|
||||
_LOG.debug("Write bsddb version %s" % str(dbase.version()))
|
||||
with open(versionpath, "w") as version_file:
|
||||
version_file.write(str(dbase.version()))
|
||||
dbase.load(new_path, callback)
|
||||
|
||||
import_function = plugin.get_import_function()
|
||||
|
||||
@@ -154,6 +154,15 @@ class CLIDbLoader(object):
|
||||
try:
|
||||
self.dbstate.db.load(filename, self._pulse_progress, mode)
|
||||
self.dbstate.db.set_save_path(filename)
|
||||
except gen.db.exceptions.DbEnvironmentError, msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog( _("Cannot open database"), str(msg))
|
||||
except gen.db.exceptions.BsddbUpgradeRequiredError, msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog( _("Cannot open database"), str(msg))
|
||||
except gen.db.exceptions.BsddbDowngradeError, msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog( _("Cannot open database"), str(msg))
|
||||
except gen.db.exceptions.DbUpgradeRequiredError, msg:
|
||||
self.dbstate.no_database()
|
||||
self._errordialog( _("Cannot open database"), str(msg))
|
||||
|
||||
Reference in New Issue
Block a user