]> git.ipfire.org Git - pakfire.git/commitdiff
Fix calculation of total download size.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Feb 2011 17:18:16 +0000 (18:18 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Feb 2011 17:18:16 +0000 (18:18 +0100)
pakfire/depsolve.py
pakfire/packages/base.py
pakfire/packages/file.py
pakfire/transaction.py

index 133b4c8e1bc538e2b47bb14407ae30f310413553..5653cf670f3735975768f6ced229ffd720095fc0 100644 (file)
@@ -235,9 +235,11 @@ class DependencySet(object):
                        s.append(format % (_("Remove"),
                                len(self.ts.removes + self.ts.remove_deps), _("Package(s)")))
 
-               download_size = sum([p.size for p in self.ts.installs + \
-                       self.ts.install_deps + self.ts.updates + self.ts.update_deps])
-               s.append(_("Total download size: %s") % util.format_size(download_size))
+               # Calculate the size of all files that need to be downloaded this this
+               # transaction.
+               download_size = sum([p.size for p in self.ts.downloads])
+               if download_size:
+                       s.append(_("Total download size: %s") % util.format_size(download_size))
                s.append("")
 
                for line in s:
index 7159cb20b215a12605521446368ae69d29208258..c2f8db92fe3a01e03d61c0bf868e2fa0c579b347 100644 (file)
@@ -106,6 +106,14 @@ class Package(object):
                """
                return 0
 
+       @property
+       def local(self):
+               """
+                       Indicates whether a package is located "local" means on disk
+                       and has not be downloaded.
+               """
+               return False
+
        ### META INFORMATION ###
 
        @property
index 1f73b627323dc664de5beb449c7120d33bb1f426..1f819fd1c2d1c75b9531e422105b52c042691a91 100644 (file)
@@ -41,6 +41,11 @@ class FilePackage(Package):
                if self._archive:
                        self._archive.close()
 
+       @property
+       def local(self):
+               # A file package is always local.
+               return True
+
        @property
        def archive(self):
                if not self._archive:
index 9ff29b60caf74acb56f7ab6801d8a76b5b141912..90bdfc9ffa449e5cbf9cfce942d66d5bd7185ff8 100644 (file)
@@ -101,6 +101,18 @@ class TransactionSet(object):
                self.removes = []
                self.remove_deps = []
 
+       @property
+       def downloads(self):
+               """
+                       Return a list containing all packages that need to be downloaded.
+               """
+               for pkg in self.installs + self.install_deps + self.updates + self.update_deps:
+                       # Skip all packages that are already local.
+                       if pkg.local:
+                               continue
+
+                       yield pkg
+
        def install(self, pkg, dep=False):
                logging.info(" --> Marking package for install: %s" % pkg.friendly_name)