svn: r8314
This commit is contained in:
parent
d20b4833f9
commit
ec0623d67d
@ -2470,7 +2470,7 @@ class Transaction:
|
|||||||
by the object's serialize method.
|
by the object's serialize method.
|
||||||
"""
|
"""
|
||||||
self.last = self.db.append(
|
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:
|
if self.first == None:
|
||||||
self.first = self.last
|
self.first = self.last
|
||||||
|
|
||||||
|
@ -47,13 +47,9 @@ from QuestionDialog import ErrorDialog
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
import time
|
|
||||||
|
|
||||||
LOG = logging.getLogger(".Backukp")
|
LOG = logging.getLogger(".Backukp")
|
||||||
|
|
||||||
def __base_dir(database):
|
|
||||||
return os.path.dirname(database.get_save_path())
|
|
||||||
|
|
||||||
def export(database):
|
def export(database):
|
||||||
try:
|
try:
|
||||||
do_export(database)
|
do_export(database)
|
||||||
@ -64,32 +60,29 @@ def export(database):
|
|||||||
|
|
||||||
def do_export(database):
|
def do_export(database):
|
||||||
|
|
||||||
t = time.time()
|
|
||||||
|
|
||||||
tables = [
|
tables = [
|
||||||
('person', database.person_map.db),
|
('person', database.person_map.db),
|
||||||
('family', database.family_map.db),
|
('family', database.family_map.db),
|
||||||
('place', database.place_map.db),
|
('place', database.place_map.db),
|
||||||
('source', database.place_map.db),
|
('source', database.source_map.db),
|
||||||
('repo', database.repository_map.db),
|
('repo', database.repository_map.db),
|
||||||
('note', database.note_map.db),
|
('note', database.note_map.db),
|
||||||
('media', database.media_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:
|
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")
|
||||||
print backup_name
|
|
||||||
backup_table = open(backup_name, 'w')
|
backup_table = open(backup_name, 'w')
|
||||||
|
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
d = cursor.first()
|
d = cursor.first()
|
||||||
while d:
|
while d:
|
||||||
backup_table.write(d[1])
|
pickle.dump(d[1], backup_table, 2)
|
||||||
d = cursor.next()
|
d = cursor.next()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
backup_table.close()
|
backup_table.close()
|
||||||
print time.time() - t
|
|
||||||
|
|
||||||
def restore(database):
|
def restore(database):
|
||||||
try:
|
try:
|
||||||
@ -101,8 +94,6 @@ def restore(database):
|
|||||||
|
|
||||||
def do_restore(database):
|
def do_restore(database):
|
||||||
|
|
||||||
t = time.time()
|
|
||||||
|
|
||||||
tables = [
|
tables = [
|
||||||
('person', database.person_map),
|
('person', database.person_map),
|
||||||
('family', database.family_map),
|
('family', database.family_map),
|
||||||
@ -115,12 +106,12 @@ def do_restore(database):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for (base, db) in tables:
|
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')
|
backup_table = open(backup_name, 'r')
|
||||||
|
|
||||||
for line in backup_table:
|
try:
|
||||||
data = pickle.loads(line)
|
while True:
|
||||||
db[data[0]] = data
|
db[data[0]] = pickle.load(backup_table)
|
||||||
backup_table.close()
|
except EOFError:
|
||||||
print time.time() - t
|
backup_table.close()
|
||||||
|
|
||||||
|
@ -531,8 +531,8 @@ class ViewManager:
|
|||||||
Backup the current file as an XML file.
|
Backup the current file as an XML file.
|
||||||
"""
|
"""
|
||||||
import GrampsDbUtils
|
import GrampsDbUtils
|
||||||
|
|
||||||
if self.state.db.undoindex > 0:
|
if self.state.db.undoindex >= 0:
|
||||||
self.uistate.set_busy_cursor(1)
|
self.uistate.set_busy_cursor(1)
|
||||||
self.uistate.progress.show()
|
self.uistate.progress.show()
|
||||||
self.uistate.push_message(self.state, _("Autobackup..."))
|
self.uistate.push_message(self.state, _("Autobackup..."))
|
||||||
|
Loading…
Reference in New Issue
Block a user