* an option to force building of files db

* optimize: do not store paths in files db
* fix: destroy db: use db.remove
This commit is contained in:
Eray Özkural
2006-03-17 20:41:10 +00:00
parent 243139921a
commit 4e8c53300f
3 changed files with 13 additions and 8 deletions
+6 -2
View File
@@ -747,15 +747,19 @@ If package specs are given, they should be the names of package dirs under /var/
name = ("rebuild-db", "rdb")
def options(self):
self.parser.add_option("-f", "--files", action="store_true",
default=False, help=_("rebuild files database"))
def run(self):
if self.args:
self.init(database=True)
for package_fn in self.args:
pisi.api.resurrect_package(package_fn)
pisi.api.resurrect_package(package_fn, ctx.get_option('files`'))
else:
self.init(database=False)
if ctx.ui.confirm(_('Rebuild PISI databases?')):
pisi.api.rebuild_db()
pisi.api.rebuild_db(ctx.get_option('files'))
self.finalize()
+6 -5
View File
@@ -57,7 +57,9 @@ class FilesDB(shelve.LockedDBShelf):
def add_files(self, pkg_name, files, txn = None):
def proc(txn):
for x in files.list:
self.put(str(x.path), (pkg_name, x), txn)
path = x.path
del x.path
self.put(path, (pkg_name, x), txn)
self.txn_proc(proc, txn)
def remove_files(self, files, txn = None):
@@ -76,18 +78,17 @@ class FilesDB(shelve.LockedDBShelf):
if not self.has_key(path, txn):
return None
else:
return self.get(path, txn)
(name, fileinfo) = self.get(path, txn)
fileinfo.path = path
return (name, fileinfo)
return self.txn_proc(proc, txn)
def match_files(self, glob):
# NB: avoid using, this reads the entire db
import fnmatch
glob = str(glob)
infos = []
for key in self.keys():
if fnmatch.fnmatch(key, glob):
infos.append(self[key])
return infos
+1 -1
View File
@@ -100,7 +100,7 @@ class LockedDBShelf(shelve.DBShelf):
self.open(filename, dbname, filetype, flags, mode)
def destroy(self):
os.unlink(self.filename)
self.remove(self.filename)
def __del__(self):
# superclass does something funky, we don't need that