[Yum-devel] [PATCH 1/2] correct searchFiles for primary file search

Seth Vidal skvidal at fedoraproject.org
Wed Aug 26 21:48:31 UTC 2009


when we performing searchFiles() against the sqlitesacks we were not checking
if the file names were from the set of files that the primarydb has already.
So we were downloading the filelistsdb in a bunch of cases where we simply
didn't need to. This fixes the simple case of: there are no globs and the
file is a primary. It also marks a fixme to be finished that there are
globs but the globs matches up to a primarydb file. I'll get to that one shortly.
---
 yum/sqlitesack.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 5b75cf5..ca7ae74 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -862,6 +862,30 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
             name = name[:-1]
        
         pkgs = []
+
+        # ultra simple optimization - no globs and one of the primary files
+        sql_params = []
+        name_check = ""
+        if not glob and not file_glob and misc.re_primary_filename(name):
+            (pattern, esc) = self._sql_esc(name)
+            name_check = "name = ?"
+            sql_params.append(name)
+            
+            for (rep,cache) in self.primarydb.items():
+                if rep in self._all_excludes:
+                    continue
+
+                cur = cache.cursor()
+
+                executeSQL(cur, "select pkgKey from files where \
+                             %s" % (name_check), sql_params)
+                self._sql_pkgKey2po(rep, cur, pkgs)
+            pkgs = misc.unique(pkgs)
+            return pkgs
+        
+        # FIXME - easy optimization fileglob but still a primary_filename/dirname
+        
+        
         if len(self.filelistsdb) == 0:
             # grab repo object from primarydb and force filelists population in this sack using repo
             # sack.populate(repo, mdtype, callback, cacheonly)
-- 
1.6.2.5



More information about the Yum-devel mailing list