]> git.ipfire.org Git - pakfire.git/commitdiff
http: Pick mirror when downloading
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Dec 2016 00:14:54 +0000 (01:14 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Dec 2016 00:14:54 +0000 (01:14 +0100)
This avoids some unnecessary work when mirrors are added
(because mirror lists can be large) and unnecessary log
messages.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/http.py

index dd34285a8fdbe0fd851c26432ed80c060da480c5..00ede38c1d7c5196ff4475fa31198e0a7a68a217 100644 (file)
@@ -105,9 +105,6 @@ class Client(object):
                self._mirrors.append(m)
                self._mirrors.sort()
 
-               # (Re-)select the best/first mirror
-               self._next_mirror()
-
        @property
        def mirror(self):
                """
@@ -283,6 +280,10 @@ class Client(object):
                if message is None:
                        message = os.path.basename(url)
 
+               # Initialize mirrors if not done, yet
+               if self.mirrors and not self.mirror:
+                       self._next_mirror()
+
                try:
                        while True:
                                with self._make_progressbar(message) as p: