* 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
+17 -12
View File
@@ -324,13 +324,17 @@ def delete_cache():
def rebuild_db(files=False): def rebuild_db(files=False):
def destroy(files): def destroy(files):
from pisi.lockeddbshelve import LockedDBShelf
for db in os.listdir(ctx.config.db_dir()): for db in os.listdir(ctx.config.db_dir()):
if db.startswith('files') or db.startswith('filesdbversion'): if db.endswith('.bdb'): # delete only db files
clean = files if db.startswith('files') or db.startswith('filesdbversion'):
else: clean = files
clean = True else:
if clean: clean = True
os.unlink(pisi.util.join_path(ctx.config.db_dir(), db)) if clean:
fn = pisi.util.join_path(ctx.config.db_dir(), db)
#ctx.dbenv.dbremove(fn)
os.unlink(fn)
def reload(files, txn): def reload(files, txn):
for package_fn in os.listdir( pisi.util.join_path( ctx.config.lib_dir(), 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) ctx.ui.debug('Resurrecting %s' % package_fn)
pisi.api.resurrect_package(package_fn, files, txn) 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 # save parameters and shutdown pisi
options = ctx.config.options options = ctx.config.options
ui = ctx.ui ui = ctx.ui
comar = ctx.comar comar = ctx.comar
finalize() 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 # construct new database version
init(database=True, options=options, ui=ui, comar=comar) init(database=True, options=options, ui=ui, comar=comar)
#ctx.txn_proc(reload) #ctx.txn_proc(reload)
+3 -1
View File
@@ -100,7 +100,9 @@ class LockedDBShelf(shelve.DBShelf):
self.open(filename, dbname, filetype, flags, mode) self.open(filename, dbname, filetype, flags, mode)
def destroy(self): def destroy(self):
self.remove(self.filename) os.unlink(self.filename)
#self.close()
#self.db.remove(self.filename)
def __del__(self): def __del__(self):
# superclass does something funky, we don't need that # superclass does something funky, we don't need that