* fix: butcher only db files in rebuilddb, couldn't yet
figure out how to dbenv.dbremove
This commit is contained in:
+12
-7
@@ -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.endswith('.bdb'): # delete only db files
|
||||||
if db.startswith('files') or db.startswith('filesdbversion'):
|
if db.startswith('files') or db.startswith('filesdbversion'):
|
||||||
clean = files
|
clean = files
|
||||||
else:
|
else:
|
||||||
clean = True
|
clean = True
|
||||||
if clean:
|
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):
|
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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user