[yum-commits] Branch 'yum-3_2_X' - 3 commits - yum/sqlitesack.py

skvidal at osuosl.org skvidal at osuosl.org
Thu Aug 27 15:26:40 UTC 2009


 yum/sqlitesack.py |   43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

New commits:
commit 889aeba249382ca9f5ce42c784b3f32aa5d0deb5
Merge: 2d68720... 9769505...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Aug 27 11:23:30 2009 -0400

    Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
    
    * 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
      Clean up unnecessary/duplicated code.
      Fix script error output for erase transactions (bz#484729).
      Cleanup doUpdate. availdict to newpkgs altered as we itered (minor speedup)
      Fix makelists for reinstall, now that we've changed how they happen
      Remove erase transactions on reinstall, fixes BZ 512393.
      Optimization for pkgExcluder, if we have no excluders do nothing.

commit 2d687208429109d28aadf925ae4183c5d928bfc8
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Aug 26 17:46:40 2009 -0400

    add _search_primary_files() to sqliteSack and make it handle glob'd filenames
    but not glob'd DIRECTORY names properly for the normal-ish cases.
    
    This should get _search(), searchPrco, and searchFiles() on roughly the same page.
    
    future note: we need to make a lot of this die in a fire.

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index ca7ae74..876140c 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -835,6 +835,22 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         return skip_all
 
     @catchSqliteException
+    def _search_primary_files(self, name):
+        querytype = 'glob'
+        if not misc.re_glob(name):
+            querytype = '='        
+        results = []
+        
+        for (rep,cache) in self.primarydb.items():
+            if rep in self._all_excludes:
+                continue
+            cur = cache.cursor()
+            executeSQL(cur, "select DISTINCT pkgKey from files where name %s ?" % querytype, (name,))
+            self._sql_pkgKey2po(rep, cur, results)
+
+        return misc.unique(results)
+        
+    @catchSqliteException
     def searchFiles(self, name, strict=False):
         """search primary if file will be in there, if not, search filelists, use globs, if possible"""
         
@@ -863,28 +879,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
        
         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
-        
+        # ultra simple optimization 
+        if misc.re_primary_filename(name):
+            if not misc.re_glob(dirname): # is the dirname a glob?
+                return self._search_primary_files(name)
         
         if len(self.filelistsdb) == 0:
             # grab repo object from primarydb and force filelists population in this sack using repo
@@ -1201,18 +1199,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
             return result
 
         # If it is a filename, search the primary.xml file info
-        for (rep,cache) in self.primarydb.items():
-            if rep in self._all_excludes:
-                continue
-
-            cur = cache.cursor()
-            executeSQL(cur, "select DISTINCT pkgKey from files where name = ?", (name,))
-            for ob in cur:
-                pkg = self._packageByKey(rep, ob['pkgKey'])
-                if pkg is None:
-                    continue
-                result[pkg] = [(name, None, None)]
-        self._search_cache[prcotype][req] = result
+        
+        for pkg in self._search_primary_files(name):
+            result[pkg] = [(name, None, None)]
+            self._search_cache[prcotype][req] = result
         return result
 
     def getProvides(self, name, flags=None, version=(None, None, None)):
@@ -1293,10 +1283,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
             return results
 
         # If it is a filename, search the primary.xml file info
-        for (rep,cache) in self.primarydb.items():
-            cur = cache.cursor()
-            executeSQL(cur, "select DISTINCT pkgKey from files where name %s ?" % querytype, (name,))
-            self._sql_pkgKey2po(rep, cur, results)
+        results.extend(self._search_primary_files(name))
 
         # if its in the primary.xml files then skip the other check
         if misc.re_primary_filename(name) and not glob:
commit bab7170623c6f42f0e7898f3876380b861dff032
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Aug 26 07:34:45 2009 -0400

    correct searchFiles for primary file search
    
    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.

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)


More information about the Yum-commits mailing list