From edf249ffd6aa4a9ede772f734d3da6979d25d9ea Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sun, 26 Nov 2006 19:47:34 +0000 Subject: [PATCH] 2006-11-26 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (load): Clean env for a new grdb file; do not attempt recovery for a new grdb file. * NEWS: Typo. svn: r7707 --- gramps2/ChangeLog | 5 +++++ gramps2/src/GrampsDb/_GrampsBSDDB.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 938f94a4f..13c804f27 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2006-11-26 Alex Roitman + * src/GrampsDb/_GrampsBSDDB.py (load): Clean env for a new grdb + file; do not attempt recovery for a new grdb file. + * NEWS: Typo. + 2006-11-26 Don Allingham * src/docgen/ODFDoc.py: fix registration diff --git a/gramps2/src/GrampsDb/_GrampsBSDDB.py b/gramps2/src/GrampsDb/_GrampsBSDDB.py index 724331944..0627471b7 100644 --- a/gramps2/src/GrampsDb/_GrampsBSDDB.py +++ b/gramps2/src/GrampsDb/_GrampsBSDDB.py @@ -348,9 +348,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): self.env.set_flags(db.DB_LOG_AUTOREMOVE,1) # clean up unused logs # The DB_PRIVATE flag must go if we ever move to multi-user setup - env_flags = db.DB_CREATE|db.DB_RECOVER|db.DB_PRIVATE|\ + env_flags = db.DB_CREATE|db.DB_PRIVATE|\ db.DB_INIT_MPOOL|db.DB_INIT_LOCK|\ db.DB_INIT_LOG|db.DB_INIT_TXN|db.DB_THREAD + # Only do recovery for existing databases + if os.path.isfile(self.full_name): + env_flags = env_flags | db.DB_RECOVER # Environment name is now based on the filename env_name = os.path.join(os.path.expanduser(const.env_dir), @@ -367,6 +370,13 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): if os.path.isdir(common_env_name): shutil.rmtree(env_name) shutil.copytree(common_env_name,env_name) + else: + # For existing env and new database, clean the env + # (means the env dir remains from previous db + # with the same name) + if not os.path.isfile(self.full_name): + shutil.rmtree(env_name) + os.mkdir(env_name) else: env_flags = db.DB_CREATE|db.DB_PRIVATE|db.DB_INIT_MPOOL