* fix: butcher only db files in rebuilddb, couldn't yet

figure out how to dbenv.dbremove
This commit is contained in:
Eray Özkural
2006-03-17 23:52:03 +00:00
parent a7e2e6ee1a
commit 855b5265c2
2 changed files with 20 additions and 13 deletions
+12 -7
View File
@@ -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.endswith('.bdb'): # delete only db files
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))
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)
+3 -1
View File
@@ -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