2007-06-13 Don Allingham <don@gramps-project.org>

* src/DbManager.py: handle broken dbs that have been opened
	* src/DbState.py: handle broken dbs that have been opened
	* src/GrampsDbUtils/_Backup.py: write intermediate file firs to make
	sure no errors occur when writing, then replace old backups

	* src/ViewManager.py: better rebuild recovery
	* src/GrampsDb/_GrampsDbConst.py: better rebuild recovery
	* src/GrampsDb/_GrampsDBCallback.py: better rebuild recovery
	* src/DbManager.py: better rebuild recovery
	* src/glade/gramps.glade: better rebuild recovery
	* src/const.py.in: better rebuild recovery
	* src/QuestionDialog.py: better rebuild recovery
	* src/GrampsDbUtils/_ReadGedcom.py: better rebuild recovery
	* src/ArgHandler.py: better rebuild recovery
	* src/DbLoader.py: better rebuild recovery

2007-06-12  Don Allingham  <don@gramps-project.org>


svn: r8546
This commit is contained in:
Don Allingham 2007-06-13 22:48:28 +00:00
parent 106d6447fd
commit 76e590472f
4 changed files with 43 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2007-06-13 Don Allingham <don@gramps-project.org>
* src/DbManager.py: handle broken dbs that have been opened
* src/DbState.py: handle broken dbs that have been opened
* src/GrampsDbUtils/_Backup.py: write intermediate file firs to make
sure no errors occur when writing, then replace old backups
2007-06-13 Brian Matherly <brian@gramps-project.org> 2007-06-13 Brian Matherly <brian@gramps-project.org>
* src/plugins/GraphViz.py: Improve tooltip for latin-1 option. * src/plugins/GraphViz.py: Improve tooltip for latin-1 option.
@ -15,6 +21,18 @@
* src/plugins/DetAncestralReport.py: * src/plugins/DetAncestralReport.py:
Enhance the source endnotes in some text reports. Enhance the source endnotes in some text reports.
2007-06-12 Don Allingham <don@gramps-project.org>
* src/ViewManager.py: better rebuild recovery
* src/GrampsDb/_GrampsDbConst.py: better rebuild recovery
* src/GrampsDb/_GrampsDBCallback.py: better rebuild recovery
* src/DbManager.py: better rebuild recovery
* src/glade/gramps.glade: better rebuild recovery
* src/const.py.in: better rebuild recovery
* src/QuestionDialog.py: better rebuild recovery
* src/GrampsDbUtils/_ReadGedcom.py: better rebuild recovery
* src/ArgHandler.py: better rebuild recovery
* src/DbLoader.py: better rebuild recovery
2007-06-12 Don Allingham <don@gramps-project.org> 2007-06-12 Don Allingham <don@gramps-project.org>
* src/ViewManager.py: detection and recovery from db errors * src/ViewManager.py: detection and recovery from db errors
* src/GrampsDb/_GrampsDBDir.py: detection and recovery from db errors * src/GrampsDb/_GrampsDBDir.py: detection and recovery from db errors

View File

@ -239,7 +239,8 @@ class DbManager:
name = file(path_name).readline().strip() name = file(path_name).readline().strip()
(tval, last) = time_val(dirpath) (tval, last) = time_val(dirpath)
(enable, stock_id) = icon_values(dirpath, self.active) (enable, stock_id) = icon_values(dirpath, self.active,
self.dbstate.db.is_open())
self.current_names.append( self.current_names.append(
(name, os.path.join(DEFAULT_DIR, dpath), path_name, (name, os.path.join(DEFAULT_DIR, dpath), path_name,
@ -444,15 +445,15 @@ def time_val(dirpath):
last = _("Never") last = _("Never")
return (tval, last) return (tval, last)
def icon_values(dirpath, active): def icon_values(dirpath, active, open):
""" """
If the directory path is the active path, then return values If the directory path is the active path, then return values
that indicate to use the icon, and which icon to use. that indicate to use the icon, and which icon to use.
""" """
if dirpath == active:
return (True, gtk.STOCK_OPEN)
if os.path.isfile(os.path.join(dirpath,"need_recover")): if os.path.isfile(os.path.join(dirpath,"need_recover")):
return (True, gtk.STOCK_DIALOG_ERROR) return (True, gtk.STOCK_DIALOG_ERROR)
elif dirpath == active and open:
return (True, gtk.STOCK_OPEN)
else: else:
return (False, "") return (False, "")

View File

@ -114,6 +114,7 @@ class DbState(GrampsDBCallback):
""" """
self.db.close() self.db.close()
self.db = GrampsDbBase() self.db = GrampsDbBase()
self.db.db_is_open = False
self.active = None self.active = None
self.open = False self.open = False
self.emit('database-changed', (self.db, )) self.emit('database-changed', (self.db, ))

View File

@ -72,17 +72,26 @@ def __do_export(database):
@param database: database instance to backup @param database: database instance to backup
@type database: GrampsDbDir @type database: GrampsDbDir
""" """
for (base, tbl) in __build_tbl_map(database): try:
backup_name = os.path.join(database.get_save_path(), base + ".gbkp") for (base, tbl) in __build_tbl_map(database):
backup_table = open(backup_name, 'wb') backup_name = os.path.join(database.get_save_path(), base + ".gbkp.new")
backup_table = open(backup_name, 'wb')
cursor = tbl.cursor() cursor = tbl.cursor()
data = cursor.first() data = cursor.first()
while data: while data:
pickle.dump(data, backup_table, 2) pickle.dump(data, backup_table, 2)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
backup_table.close() backup_table.close()
except (IOError,OSError):
return
for (base, tbl) in __build_tbl_map(database):
new_name = os.path.join(database.get_save_path(), base + ".gbkp")
old_name = new_name + ".new"
os.unlink(new_name)
os.rename(old_name, new_name)
def restore(database): def restore(database):
""" """