From 39097e291ae050dbefe2dfa265e55dd330328acd Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 19 Apr 2012 16:56:03 +0200 Subject: [PATCH] Fix adding right package format to all actions in the transaction. --- python/pakfire/transaction.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/python/pakfire/transaction.py b/python/pakfire/transaction.py index 0b417d26d..58b52c697 100644 --- a/python/pakfire/transaction.py +++ b/python/pakfire/transaction.py @@ -301,7 +301,7 @@ class Transaction(object): @property def downloads(self): - return sorted([a for a in self.actions if a.needs_download]) + return sorted([a.pkg_solv for a in self.actions if a.needs_download]) def download(self, logger=None): if logger is None: @@ -309,16 +309,13 @@ class Transaction(object): # Get all download actions as a list. downloads = [d for d in self.downloads] - downloads.sort() # If there are no downloads, we can just stop here. if not downloads: return # Calculate downloadsize. - download_size = 0 - for action in downloads: - download_size += action.pkg.size + download_size = sum([d.size for d in downloads]) # Get free space of the download location. path = os.path.realpath(REPO_CACHE_DIR) @@ -334,9 +331,19 @@ class Transaction(object): time_start = time.time() i = 0 - for action in downloads: + for pkg in downloads: i += 1 - action.download(text="(%d/%d): " % (i, len(downloads)), logger=logger) + + # Download the package file. + bin_pkg = pkg.download(text="(%d/%d): " % (i, len(downloads)), logger=logger) + + # Search in every action if we need to replace the package. + for action in self.actions: + if not action.pkg_solv.uuid == bin_pkg.uuid: + continue + + # Replace the package. + action.pkg = bin_pkg # Write an empty line to the console when there have been any downloads. width, height = util.terminal_size() @@ -420,7 +427,7 @@ class Transaction(object): # Calculate the size of all files that need to be downloaded this this # transaction. - download_size = sum([a.pkg.size for a in self.downloads]) + download_size = sum([d.size for d in self.downloads]) if download_size: s.append(_("Total download size: %s") % util.format_size(download_size)) -- 2.39.5