* fix: raise error when dbversion not present and in read mode
* fix: do not try to init dbenv unnecessarily
This commit is contained in:
+1
-1
@@ -336,9 +336,9 @@ def rebuild_db(files=False):
|
||||
|
||||
def destroy(files):
|
||||
#from pisi.lockeddbshelve import LockedDBShelf
|
||||
#pisi.lockeddbshelve.init_dbenv(write=True)
|
||||
#TODO: either don't delete version files here, or remove force flag...
|
||||
import bsddb3.db
|
||||
pisi.lockeddbshelve.init_dbenv(write=True)
|
||||
for db in os.listdir(ctx.config.db_dir()):
|
||||
if db.endswith('.bdb') or db.startswith('log'): # delete only db files
|
||||
if db.startswith('files') or db.startswith('filesdbversion'):
|
||||
|
||||
@@ -54,12 +54,14 @@ def check_dbversion(versionfile, ver, write=False, force=False):
|
||||
return True # return if force not set and db version ok
|
||||
if write:
|
||||
if os.access(pisi.context.config.db_dir(), os.W_OK):
|
||||
ctx.ui.warning(_('Writing current database version'))
|
||||
ctx.ui.warning(_('Writing current database version for %s') % versionfile)
|
||||
verfile = file(verfn, 'w')
|
||||
verfile.write(ver)
|
||||
verfile.close()
|
||||
else:
|
||||
raise Error(_('Cannot attain write access to database environment'))
|
||||
else:
|
||||
raise Error(_('Database version %s not present.') % versionfile)
|
||||
|
||||
def init_dbenv(write=False, writeversion=False):
|
||||
if os.access(pisi.context.config.db_dir(), os.R_OK):
|
||||
|
||||
Reference in New Issue
Block a user