@@ -54,11 +54,16 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
5454 else :
5555 mirrors = {}
5656
57+ try :
58+ schema .MirrorsValidator .validate (mirrors )
59+ except ValueError as err :
60+ raise MirrorError ("Mirror config does not comply with schema.\n {err}" )
61+
5762 # Add or set the cache given on the command line as the buildcache destination
5863 if cmdline_cache is not None :
5964 # If the mirror name given on the command line isn't in the config, assume it
6065 # is the URL to a build cache.
61- if cmdline_cache in mirrors :
66+ if cmdline_cache not in mirrors :
6267 mirrors ['cmdline_cache' ] = {
6368 'url' : cmdline_cache ,
6469 'description' : "Cache configured via command line." ,
@@ -74,16 +79,10 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
7479 mirror ['cache' ] = True
7580
7681 # Load the cache as defined by the deprecated 'cache.yaml' file.
77- mirrors ['legacy_cache_cfg' ] = self ._load_legacy_cache ()
78-
82+ legacy_cache = self ._load_legacy_cache ()
83+ if legacy_cache is not None :
84+ mirrors ['legacy_cache_cfg' ] = legacy_cache
7985
80- try :
81- # validate the yaml, including anything we added
82- schema .MirrorsValidator .validate (mirrors )
83- except ValueError as err :
84- raise MirrorError (
85- "Mirror config does not comply with schema.\n {err}"
86- )
8786
8887 caches = [mirror for mirror in mirrors .values () if mirror ['cache' ]]
8988 if len (caches ) > 1 :
@@ -92,7 +91,7 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
9291 "Some of these may have come from a legacy 'cache.yaml' or the '--cache' option.\n "
9392 f"{ self ._pp_yaml (caches )} " )
9493
95- return {name : mirror for name , mirror in raw .items () if mirror ["enabled" ]}
94+ return {name : mirror for name , mirror in mirrors .items () if mirror ["enabled" ]}
9695
9796 @staticmethod
9897 def _pp_yaml (object ):
0 commit comments