@@ -45,12 +45,12 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
4545 """Load the mirrors file, if one exists."""
4646 path = self ._system_config_root / "mirrors.yaml"
4747 if path .exists ():
48- with path . open () as fid :
49- # load the raw yaml input
50- mirrors = yaml . load ( fid , Loader = yaml . SafeLoader )
51-
52- # validate the yaml
53- schema . MirrorsValidator . validate ( mirrors )
48+ try :
49+ with path . open () as fid :
50+ # load the raw yaml input
51+ mirrors = yaml . load ( fid , Loader = yaml . SafeLoader )
52+ except ( OSError , PermissionError ) as err :
53+ raise MirrorError ( "Could not open/read mirrors.yaml file. \n {err}" )
5454 else :
5555 mirrors = {}
5656
@@ -62,6 +62,7 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
6262 mirrors ['cmdline_cache' ] = {
6363 'url' : cmdline_cache ,
6464 'description' : "Cache configured via command line." ,
65+ 'enabled' : True ,
6566 'cache' : True ,
6667 'bootstrap' : False ,
6768 'mount_specific' : True ,
@@ -75,6 +76,15 @@ def _load_mirrors(self, cmdline_cache: Optional[str]) -> Dict[str, Dict]:
7576 # Load the cache as defined by the deprecated 'cache.yaml' file.
7677 mirrors ['legacy_cache_cfg' ] = self ._load_legacy_cache ()
7778
79+
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+ )
87+
7888 caches = [mirror for mirror in mirrors .values () if mirror ['cache' ]]
7989 if len (caches ) > 1 :
8090 raise MirrorError (
@@ -115,7 +125,8 @@ def _load_legacy_cache(self):
115125 mirror_cfg = {
116126 'url' : f'file://{ raw ['root' ]} ' ,
117127 'description' : "Buildcache dest loaded from legacy cache.yaml" ,
118- 'buildcache_push' : True ,
128+ 'cache' : True ,
129+ 'enabled' : True ,
119130 'mount_specific' : True ,
120131 'private_key' : raw ['key' ],
121132 }
0 commit comments