From 855b5265c24f4731594de2415f5661b67d7e6ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Fri, 17 Mar 2006 23:52:03 +0000 Subject: [PATCH] * fix: butcher only db files in rebuilddb, couldn't yet figure out how to dbenv.dbremove --- pisi/api.py | 29 +++++++++++++++++------------ pisi/lockeddbshelve.py | 4 +++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index c874fbc8..878fd372 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -324,13 +324,17 @@ def delete_cache(): def rebuild_db(files=False): def destroy(files): + from pisi.lockeddbshelve import LockedDBShelf for db in os.listdir(ctx.config.db_dir()): - if db.startswith('files') or db.startswith('filesdbversion'): - clean = files - else: - clean = True - if clean: - os.unlink(pisi.util.join_path(ctx.config.db_dir(), db)) + if db.endswith('.bdb'): # 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) + os.unlink(fn) def reload(files, txn): for package_fn in os.listdir( pisi.util.join_path( ctx.config.lib_dir(), @@ -339,17 +343,18 @@ def rebuild_db(files=False): ctx.ui.debug('Resurrecting %s' % package_fn) pisi.api.resurrect_package(package_fn, files, txn) + try: + pisi.lockeddbshelve.check_dbversion('filesdbversion', pisi.__filesdbversion__, write=False) + except: + files = True # exception means the files db version was wrong + pisi.lockeddbshelve.init_dbenv() + destroy(files) # bye bye + ctx.dbenv.close() # save parameters and shutdown pisi options = ctx.config.options ui = ctx.ui comar = ctx.comar finalize() - - try: - pisi.lockeddbshelve.check_dbversion('filesdbversion', pisi.__filesdbversion__, write=False) - except: - files = True # exception means the files db version was wrong - destroy(files) # bye bye # construct new database version init(database=True, options=options, ui=ui, comar=comar) #ctx.txn_proc(reload) diff --git a/pisi/lockeddbshelve.py b/pisi/lockeddbshelve.py index 56486cb4..35c8ff19 100644 --- a/pisi/lockeddbshelve.py +++ b/pisi/lockeddbshelve.py @@ -100,7 +100,9 @@ class LockedDBShelf(shelve.DBShelf): self.open(filename, dbname, filetype, flags, mode) def destroy(self): - self.remove(self.filename) + os.unlink(self.filename) + #self.close() + #self.db.remove(self.filename) def __del__(self): # superclass does something funky, we don't need that