From: Michael Tremer Date: Tue, 6 Dec 2016 23:41:16 +0000 (+0100) Subject: Use new HTTP client to make source packages X-Git-Tag: 0.9.28~1285^2~1401 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e468e2611eed21b32a8d75af2693b31bdba0d91;p=pakfire.git Use new HTTP client to make source packages Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/packages/make.py b/src/pakfire/packages/make.py index 1fd6e96ac..1c0b148d1 100644 --- a/src/pakfire/packages/make.py +++ b/src/pakfire/packages/make.py @@ -36,7 +36,7 @@ log = logging.getLogger("pakfire") from ..constants import * from ..i18n import _ -#from .. import downloader +from .. import http from .. import system from .. import util @@ -240,11 +240,32 @@ class Makefile(MakefileBase): Download all external sources and return a list with the local copies. """ - # Download source files. - grabber = downloader.SourceDownloader(self.pakfire, - mirrors=self.source_dl) + downloader = http.Client() + files = [] + + # Add the download mirrors to try + for source_dl in self.source_dl: + downloader.add_mirror(source_dl) + + for source in self.sources: + file = os.path.join(SOURCE_CACHE_DIR, source) + + # If the file already exists in the cache dir, there + # is no need to download it + if os.path.exists(file) and os.path.getsize(file) > 0: + log.debug("File exists in cache already: %s" % file) - return grabber.download(self.sources) + files.append(file) + continue + + # Download the file + downloader.retrieve(source, file) + files.append(file) + + assert os.path.exists(file) + + # Return the path to the files + return files def dist(self, resultdir): """