File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
wasm-pkg-client/src/caching Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ pub struct FileCache {
2020 root : PathBuf ,
2121}
2222
23+ impl std:: fmt:: Display for FileCache {
24+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
25+ write ! ( f, "{}" , self . root. display( ) )
26+ }
27+ }
28+
2329impl FileCache {
2430 /// Creates a new file cache that stores data in the given directory.
2531 pub async fn new ( root : impl AsRef < Path > ) -> anyhow:: Result < Self > {
Original file line number Diff line number Diff line change @@ -42,6 +42,16 @@ pub enum RegistryMapping {
4242 Custom ( CustomConfig ) ,
4343}
4444
45+ impl RegistryMapping {
46+ /// returns the inner [`Registry`] object for both mapping variants
47+ fn get_registry ( & self ) -> & Registry {
48+ match self {
49+ RegistryMapping :: Registry ( reg) => reg,
50+ RegistryMapping :: Custom ( custom) => & ( custom. registry ) ,
51+ }
52+ }
53+ }
54+
4555/// Custom registry configuration
4656#[ derive( Debug , Clone , Serialize , Deserialize ) ]
4757pub struct CustomConfig {
@@ -184,21 +194,15 @@ impl Config {
184194 if let Some ( reg) = self
185195 . package_registry_overrides
186196 . get ( package)
187- . map ( |m| match m {
188- RegistryMapping :: Registry ( reg) => reg,
189- RegistryMapping :: Custom ( custom) => & custom. registry ,
190- } )
197+ . map ( RegistryMapping :: get_registry)
191198 {
192199 return Some ( reg) ;
193200 }
194201
195202 if let Some ( reg) = self
196203 . namespace_registries
197204 . get ( package. namespace ( ) )
198- . map ( |m| match m {
199- RegistryMapping :: Registry ( reg) => reg,
200- RegistryMapping :: Custom ( custom) => & custom. registry ,
201- } )
205+ . map ( RegistryMapping :: get_registry)
202206 {
203207 return Some ( reg) ;
204208 }
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ impl Common {
6666 } else {
6767 FileCache :: global_cache_path ( ) . context ( "unable to find cache directory" ) ?
6868 } ;
69+
6970 FileCache :: new ( dir) . await
7071 }
7172
@@ -76,6 +77,8 @@ impl Common {
7677 let config = self . load_config ( ) . await ?;
7778 let cache = self . load_cache ( ) . await ?;
7879 let client = Client :: new ( config) ;
80+
81+ tracing:: debug!( filecache_dir = %cache) ;
7982 Ok ( CachingClient :: new ( Some ( client) , cache) )
8083 }
8184}
You can’t perform that action at this time.
0 commit comments