]> git.ipfire.org Git - pakfire.git/commitdiff
index: Search for files in a directory recursively.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Feb 2011 00:16:12 +0000 (01:16 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Feb 2011 00:16:12 +0000 (01:16 +0100)
If we have such directories like:

   abc
    |`- i686
    `-- noarch

...we need to search recursively for packages that do match
the architecture of the distribution.

pakfire/index.py

index 3617a4feb7952a37ad37c653ca86c94bfe58025c..592653ff843976e9f2325ec39935be48797337fa 100644 (file)
@@ -61,17 +61,18 @@ class DirectoryIndex(Index):
        def update(self, force=False):
                logging.debug("Updating repository index '%s' (force=%s)" % (self.path, force))
 
-               for file in os.listdir(self.path):
-                       file = os.path.join(self.path, file)
+               for dir, subdirs, files in os.walk(self.path):
+                       for file in files:
+                               file = os.path.join(dir, file)
 
-                       package = packages.BinaryPackage(file)
+                               package = packages.BinaryPackage(file)
 
-                       if not package.arch in (self.arch, "noarch"):
-                               logging.warning("Skipped package with wrong architecture: %s (%s)" \
-                                       % (package.filename, package.arch))
-                               continue
+                               if not package.arch in (self.arch, "noarch"):
+                                       logging.warning("Skipped package with wrong architecture: %s (%s)" \
+                                               % (package.filename, package.arch))
+                                       continue
 
-                       self._packages.append(package)
+                               self._packages.append(package)
 
 
 class InstalledIndex(Index):