svn: r8314

This commit is contained in:
Don Allingham 2007-03-25 03:17:25 +00:00
parent d20b4833f9
commit ec0623d67d
3 changed files with 14 additions and 23 deletions

View File

@ -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

View File

@ -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
try:
while True:
db[data[0]] = pickle.load(backup_table)
except EOFError:
backup_table.close()
print time.time() - t

View File

@ -532,7 +532,7 @@ class ViewManager:
"""
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..."))