From 4e8c53300f9da7b5bfce318fbdfa7dae835c4b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Fri, 17 Mar 2006 20:41:10 +0000 Subject: [PATCH] * an option to force building of files db * optimize: do not store paths in files db * fix: destroy db: use db.remove --- pisi/cli/commands.py | 8 ++++++-- pisi/files.py | 11 ++++++----- pisi/lockeddbshelve.py | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index f8482f9b..da9316ae 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -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() diff --git a/pisi/files.py b/pisi/files.py index 4c4cd447..ceee2fcb 100644 --- a/pisi/files.py +++ b/pisi/files.py @@ -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 diff --git a/pisi/lockeddbshelve.py b/pisi/lockeddbshelve.py index 5527a2a5..56486cb4 100644 --- a/pisi/lockeddbshelve.py +++ b/pisi/lockeddbshelve.py @@ -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