From c95dac5a29242084deff7627703d957312cf52a7 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sun, 26 Nov 2006 03:00:44 +0000 Subject: [PATCH] 2006-11-25 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (GrampsBSDDB.load): Use per-database environment dirs, under ~/.gramps/env dir. * src/const.py.in (env_dir): Add new variable. svn: r7697 --- ChangeLog | 5 +++++ src/GrampsDb/_GrampsBSDDB.py | 16 ++++++++++++++-- src/const.py.in | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 113cb5cd8..987b1b4c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-11-25 Alex Roitman + * src/GrampsDb/_GrampsBSDDB.py (GrampsBSDDB.load): Use + per-database environment dirs, under ~/.gramps/env dir. + * src/const.py.in (env_dir): Add new variable. + 2006-11-25 Don Allingham * src/Config/_GrampsConfigKeys.py: remember editor size * src/Editors/_EditPlace.py: remember editor size diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index 755d19d1a..f75c7e5ce 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -31,6 +31,7 @@ Provides the Berkeley DB (BSDDB) database backend for GRAMPS #------------------------------------------------------------------------- import cPickle as pickle import os +import shutil import re import time import locale @@ -350,9 +351,20 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): env_flags = db.DB_CREATE|db.DB_RECOVER|db.DB_PRIVATE|\ db.DB_INIT_MPOOL|db.DB_INIT_LOCK|\ db.DB_INIT_LOG|db.DB_INIT_TXN|db.DB_THREAD - env_name = os.path.expanduser(const.bsddbenv_dir) + + # Environment name is now based on the filename + env_name = os.path.join(os.path.expanduser(const.env_dir), + self.full_name[1:]) + + # Copy the old common environment dir to the new env + # if it does not exist yet if not os.path.isdir(env_name): - os.mkdir(env_name) + os.makedirs(env_name) + common_env_name = os.path.expanduser(const.bsddbenv_dir) + if os.path.isdir(common_env_name): + shutil.rmtree(env_name) + shutil.copytree(common_env_name,env_name) + else: env_flags = db.DB_CREATE|db.DB_PRIVATE|db.DB_INIT_MPOOL env_name = os.path.expanduser('~') diff --git a/src/const.py.in b/src/const.py.in index 1f57abb17..985193920 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -100,6 +100,7 @@ report_options = os.path.join(home_dir,"report_options.xml") tool_options = os.path.join(home_dir,"tool_options.xml") thumb_dir = os.path.join(home_dir,"thumb") bsddbenv_dir = os.path.join(home_dir,"bsddbenv") +env_dir = os.path.join(home_dir,"env") icon = os.path.join(root_dir,"images","gramps.png") logo = os.path.join(root_dir,"images","logo.png")