diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index 510bf2b16..7350e9918 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -2470,7 +2470,7 @@ class Transaction: by the object's serialize method. """ self.last = self.db.append( - cPickle.dumps((obj_type, handle, old_data, new_data))) + cPickle.dumps((obj_type, handle, old_data, new_data), 1)) if self.first == None: self.first = self.last diff --git a/src/GrampsDbUtils/_Backup.py b/src/GrampsDbUtils/_Backup.py index 3461866f3..473087bbb 100644 --- a/src/GrampsDbUtils/_Backup.py +++ b/src/GrampsDbUtils/_Backup.py @@ -47,13 +47,9 @@ from QuestionDialog import ErrorDialog import logging import os import cPickle as pickle -import time LOG = logging.getLogger(".Backukp") -def __base_dir(database): - return os.path.dirname(database.get_save_path()) - def export(database): try: do_export(database) @@ -64,32 +60,29 @@ def export(database): def do_export(database): - t = time.time() - tables = [ ('person', database.person_map.db), ('family', database.family_map.db), ('place', database.place_map.db), - ('source', database.place_map.db), + ('source', database.source_map.db), ('repo', database.repository_map.db), ('note', database.note_map.db), ('media', database.media_map.db), - ('event', database.media_map.db), + ('event', database.event_map.db), + ('meta_data', database.metadata.db), ] for (base, db) in tables: - backup_name = os.path.join(__base_dir(database), base + ".gbkp") - print backup_name + backup_name = os.path.join(database.get_save_path(), base + ".gbkp") backup_table = open(backup_name, 'w') cursor = db.cursor() d = cursor.first() while d: - backup_table.write(d[1]) + pickle.dump(d[1], backup_table, 2) d = cursor.next() cursor.close() backup_table.close() - print time.time() - t def restore(database): try: @@ -101,8 +94,6 @@ def restore(database): def do_restore(database): - t = time.time() - tables = [ ('person', database.person_map), ('family', database.family_map), @@ -115,12 +106,12 @@ def do_restore(database): ] for (base, db) in tables: - backup_name = os.path.join(__base_dir(database), base + ".gbkp") + backup_name = os.path.join(database.get_save_path(), base + ".gbkp") backup_table = open(backup_name, 'r') - for line in backup_table: - data = pickle.loads(line) - db[data[0]] = data - backup_table.close() - print time.time() - t + try: + while True: + db[data[0]] = pickle.load(backup_table) + except EOFError: + backup_table.close() diff --git a/src/ViewManager.py b/src/ViewManager.py index 943655543..67c9016fa 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -531,8 +531,8 @@ class ViewManager: Backup the current file as an XML file. """ import GrampsDbUtils - - if self.state.db.undoindex > 0: + + if self.state.db.undoindex >= 0: self.uistate.set_busy_cursor(1) self.uistate.progress.show() self.uistate.push_message(self.state, _("Autobackup..."))