]> git.ipfire.org Git - pakfire.git/commitdiff
Fix reading the "build" repository and give it a shiny progress bar.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2011 15:38:55 +0000 (17:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2011 15:38:55 +0000 (17:38 +0200)
pakfire/repository/index.py

index 75949d18fa6546d1e54cc24e1a56959d1aa31e1b..4714ad107c887a29429ded22597d826e81f56af3 100644 (file)
@@ -246,14 +246,33 @@ class IndexDir(Index):
                self.collect_packages(self.path)
 
        def collect_packages(self, path):
-               # XXX make progress bar for that
-               for dir, subdirs, files in os.walk(path):
-                       for file in sorted(files):
+               logging.debug("Collecting all packages from %s" % path)
+               pkgs = []
+
+               # Get a filelist of all files that could possibly be packages.
+               files = []
+               for dir, subdirs, _files in os.walk(path):
+                       for file in sorted(_files):
                                # Skip files that do not have the right extension
                                if not file.endswith(".%s" % PACKAGE_EXTENSION):
                                        continue
 
-                               package = packages.open(self.pakfire, self.repo, os.path.join(dir, file))
+                               file = os.path.join(dir, file)
+                               files.append(file)
+
+               if not files:
+                       return pkgs
+
+               # Create progress bar.
+               pb = util.make_progress(_("Loading from %s") % path, len(files))
+               i = 0
+
+               for file in files:
+                               if pb:
+                                       i += 1
+                                       pb.update(i)
+
+                               package = packages.open(self.pakfire, self.repo, file)
 
                                if isinstance(package, packages.BinaryPackage):
                                        if not package.arch in (self.repo.arch, "noarch"):
@@ -267,8 +286,12 @@ class IndexDir(Index):
                                        continue
 
                                self.add_package(package)
+                               pkgs.append(package)
+
+               if pb:
+                       pb.finish()
 
-                               yield package
+               return pkgs
 
 
 class IndexLocal(Index):