diff --git a/pisi/api.py b/pisi/api.py index 9b3a080d..88d004a0 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -336,16 +336,22 @@ def rebuild_db(files=False): def destroy(files): #from pisi.lockeddbshelve import LockedDBShelf + #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'): # delete only db files + if db.endswith('.bdb') or db.startswith('log'): # delete only db files if db.startswith('files') or db.startswith('filesdbversion'): clean = files else: clean = True if clean: fn = pisi.util.join_path(ctx.config.db_dir(), db) - #ctx.dbenv.dbremove(fn) + #FIXME: there is a bug with bsddb3 + #ctx.dbenv.dbremove(fn, "", None, bsddb3.db.DB_AUTO_COMMIT) +# ctx.dbenv.dbremove(file=fn, flags=bsddb3.db.DB_AUTO_COMMIT) os.unlink(fn) + #ctx.dbenv.close() def reload(files, txn): for package_fn in os.listdir( pisi.util.join_path( ctx.config.lib_dir(), diff --git a/pisi/itembyrepodb.py b/pisi/itembyrepodb.py index 509d3c82..8424a150 100644 --- a/pisi/itembyrepodb.py +++ b/pisi/itembyrepodb.py @@ -145,7 +145,9 @@ class ItemByRepoDB(object): repo = str(repo) def proc(txn): s = self.d.get(name, txn) - del s[self.repo_str(repo)] + repostr = self.repo_str(repo) + if s.has_key(repostr): + del s[repostr] if (len(s)==0): self.d.delete(name, txn) else: diff --git a/pisi/lockeddbshelve.py b/pisi/lockeddbshelve.py index 2b2268fa..3dae6f5a 100644 --- a/pisi/lockeddbshelve.py +++ b/pisi/lockeddbshelve.py @@ -61,11 +61,11 @@ def check_dbversion(versionfile, ver, write=False, force=False): else: raise Error(_('Cannot attain write access to database environment')) -def init_dbenv(write=False): +def init_dbenv(write=False, writeversion=False): if os.access(pisi.context.config.db_dir(), os.R_OK): # try to read version - check_dbversion('dbversion', pisi.__dbversion__, write=write) - check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write) + check_dbversion('dbversion', pisi.__dbversion__, write=writeversion) + check_dbversion('filesdbversion', pisi.__filesdbversion__, write=writeversion) else: raise Error(_('Cannot attain read access to database environment')) if os.access(pisi.context.config.db_dir(), os.W_OK):