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>
* src/plugins/GraphViz.py: Improve tooltip for latin-1 option.
@ -15,6 +21,18 @@
* src/plugins/DetAncestralReport.py:
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>
* src/ViewManager.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()
(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(
(name, os.path.join(DEFAULT_DIR, dpath), path_name,
@ -444,15 +445,15 @@ def time_val(dirpath):
last = _("Never")
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
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")):
return (True, gtk.STOCK_DIALOG_ERROR)
elif dirpath == active and open:
return (True, gtk.STOCK_OPEN)
else:
return (False, "")

View File

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

View File

@ -72,17 +72,26 @@ def __do_export(database):
@param database: database instance to backup
@type database: GrampsDbDir
"""
for (base, tbl) in __build_tbl_map(database):
backup_name = os.path.join(database.get_save_path(), base + ".gbkp")
backup_table = open(backup_name, 'wb')
try:
for (base, tbl) in __build_tbl_map(database):
backup_name = os.path.join(database.get_save_path(), base + ".gbkp.new")
backup_table = open(backup_name, 'wb')
cursor = tbl.cursor()
data = cursor.first()
while data:
pickle.dump(data, backup_table, 2)
data = cursor.next()
cursor.close()
backup_table.close()
cursor = tbl.cursor()
data = cursor.first()
while data:
pickle.dump(data, backup_table, 2)
data = cursor.next()
cursor.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):
"""