7258: Fix filesystem encoding in get_dbdir_summary and DbUndoBSDDB.close.

This commit is contained in:
John Ralls 2014-03-25 14:14:23 -07:00
parent 2221dfd79a
commit 97d3ab49c4
3 changed files with 10 additions and 4 deletions

View File

@ -64,7 +64,7 @@ _ = glocale.translation.gettext
from gramps.gen.db import DbBsddb
from gramps.gen.plug import BasePluginManager
from gramps.gen.config import config
from gramps.gen.constfunc import win, conv_to_unicode
from gramps.gen.constfunc import win, conv_to_unicode, UNITYPE
#-------------------------------------------------------------------------
#
# constants
@ -168,6 +168,8 @@ class CLIDbManager(object):
flags = db.DB_CREATE | db.DB_PRIVATE |\
db.DB_INIT_MPOOL |\
db.DB_INIT_LOG | db.DB_INIT_TXN
if (isinstance(dirpath, UNITYPE) and win() and sys.version_info[0] < 3):
dirpath = dirpath.encode(sys.getfilesystemencoding())
try:
env.open(dirpath, flags)
except Exception as msg:

View File

@ -63,7 +63,7 @@ _ = glocale.translation.gettext
# Gramps modules
#
#-------------------------------------------------------------------------
from ..constfunc import conv_to_unicode, handle2internal
from ..constfunc import conv_to_unicode, handle2internal, win, UNITYPE
from .dbconst import *
from . import BSDDBTxn
from ..errors import DbError
@ -419,7 +419,11 @@ class DbUndoBSDDB(DbUndo):
"""
Open the undo/redo database
"""
self.undodb.open(self.path, db.DB_RECNO, db.DB_CREATE)
path = (self.path.encode(sys.getfilesystemencoding())
if (isinstance(self.path, UNITYPE) and win()
and sys.version_info[0] < 3)
else self.path)
self.undodb.open(path, db.DB_RECNO, db.DB_CREATE)
def close(self):
"""

View File

@ -906,7 +906,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
Open the undo database
"""
if not self.readonly:
self.undolog = _encode(os.path.join(self.full_name, DBUNDOFN))
self.undolog = os.path.join(self.full_name, DBUNDOFN)
self.undodb = DbUndo(self, self.undolog)
self.undodb.open()