* fix: do fail when we cannot write in read-mode ops
This commit is contained in:
+15
-15
@@ -83,22 +83,22 @@ def init_dbenv(write=False, writeversion=False):
|
|||||||
check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write, update=writeversion)
|
check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write, update=writeversion)
|
||||||
else:
|
else:
|
||||||
raise Error(_('Cannot attain read access to database environment'))
|
raise Error(_('Cannot attain read access to database environment'))
|
||||||
if write and os.access(pisi.context.config.db_dir(), os.W_OK):
|
if write:
|
||||||
lock_dbenv()
|
if os.access(pisi.context.config.db_dir(), os.W_OK):
|
||||||
ctx.dbenv = dbobj.DBEnv()
|
lock_dbenv()
|
||||||
flags = (db.DB_INIT_MPOOL | # cache
|
ctx.dbenv = dbobj.DBEnv()
|
||||||
db.DB_INIT_TXN | # transaction subsystem
|
flags = (db.DB_INIT_MPOOL | # cache
|
||||||
db.DB_INIT_LOG | # logging subsystem
|
db.DB_INIT_TXN | # transaction subsystem
|
||||||
db.DB_RECOVER | # run normal recovery
|
db.DB_INIT_LOG | # logging subsystem
|
||||||
db.DB_CREATE) # allow db to create files
|
db.DB_RECOVER | # run normal recovery
|
||||||
ctx.dbenv.set_cachesize(0, 4*1024*1024)
|
db.DB_CREATE) # allow db to create files
|
||||||
ctx.dbenv.open(pisi.context.config.db_dir(), flags)
|
ctx.dbenv.set_cachesize(0, 4*1024*1024)
|
||||||
ctx.dbenv.set_flags(db.DB_LOG_AUTOREMOVE, 1) # clear inactive logs automatically
|
ctx.dbenv.open(pisi.context.config.db_dir(), flags)
|
||||||
|
ctx.dbenv.set_flags(db.DB_LOG_AUTOREMOVE, 1) # clear inactive logs automatically
|
||||||
|
else:
|
||||||
|
raise Error(_("Cannot write to PISI database."))
|
||||||
else:
|
else:
|
||||||
# Warn if not on purpose
|
ctx.dbenv = None # read-only access to database
|
||||||
if write:
|
|
||||||
ctx.ui.warning(_("Opening PISI database in read-only mode. Operations that require write access will fail."))
|
|
||||||
ctx.dbenv = None
|
|
||||||
|
|
||||||
#def open(filename, flags='r', mode = 0644, filetype = db.DB_BTREE):
|
#def open(filename, flags='r', mode = 0644, filetype = db.DB_BTREE):
|
||||||
# db = LockedDBShelf(None, mode, filetype, None, True)
|
# db = LockedDBShelf(None, mode, filetype, None, True)
|
||||||
|
|||||||
Reference in New Issue
Block a user