]> git.ipfire.org Git - pakfire.git/commitdiff
Softly fail when mirrorlist is not in cache
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 21:00:37 +0000 (22:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2017 21:00:37 +0000 (22:00 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/repository/remote.py

index b7e29f802a87327cf9946d86577b2eb7a0eeb315..f7c1b3974c0cb7222be9dbeb59186b8fc22f3878 100644 (file)
@@ -125,10 +125,16 @@ class RepositoryRemote(base.RepositoryFactory):
                """
                        Opens a cached mirror list
                """
-               with self.cache_open("mirrors", "r") as f:
-                       mirrors = json.load(f)
+               try:
+                       with self.cache_open("mirrors", "r") as f:
+                               mirrors = json.load(f)
 
-                       return mirrors.get("mirrors")
+                               return mirrors.get("mirrors")
+
+               # If there is no mirror list in the cache,
+               # we won't be able to open it
+               except IOError:
+                       pass
 
                return []