@@ -32,7 +32,10 @@ impl FilesystemCache {
3232 } ) ?;
3333 }
3434
35- Ok ( Self { cache_dir, base_dir } )
35+ Ok ( Self {
36+ cache_dir,
37+ base_dir,
38+ } )
3639 }
3740
3841 /// Create cache with default directory
@@ -63,8 +66,8 @@ impl FilesystemCache {
6366 }
6467
6568 // Walk cache directory
66- for prefix_dir in std :: fs :: read_dir ( & self . cache_dir )
67- . map_err ( |e| ConflowError :: CacheError {
69+ for prefix_dir in
70+ std :: fs :: read_dir ( & self . cache_dir ) . map_err ( |e| ConflowError :: CacheError {
6871 message : format ! ( "Failed to read cache directory: {}" , e) ,
6972 } ) ?
7073 {
@@ -78,8 +81,8 @@ impl FilesystemCache {
7881 continue ;
7982 }
8083
81- for entry_file in std :: fs :: read_dir ( & prefix_dir )
82- . map_err ( |e| ConflowError :: CacheError {
84+ for entry_file in
85+ std :: fs :: read_dir ( & prefix_dir ) . map_err ( |e| ConflowError :: CacheError {
8386 message : format ! ( "Failed to read cache subdirectory: {}" , e) ,
8487 } ) ?
8588 {
@@ -117,17 +120,17 @@ impl Cache for FilesystemCache {
117120 }
118121
119122 // Read cached entry
120- let content = tokio:: fs:: read_to_string ( & path) . await . map_err ( |e| {
121- ConflowError :: CacheError {
122- message : format ! ( "Failed to read cache entry: {}" , e) ,
123- }
124- } ) ?;
123+ let content =
124+ tokio:: fs:: read_to_string ( & path)
125+ . await
126+ . map_err ( |e| ConflowError :: CacheError {
127+ message : format ! ( "Failed to read cache entry: {}" , e) ,
128+ } ) ?;
125129
126- let entry: CachedEntry = serde_json :: from_str ( & content ) . map_err ( |e| {
127- ConflowError :: CacheError {
130+ let entry: CachedEntry =
131+ serde_json :: from_str ( & content ) . map_err ( |e| ConflowError :: CacheError {
128132 message : format ! ( "Failed to parse cache entry: {}" , e) ,
129- }
130- } ) ?;
133+ } ) ?;
131134
132135 // Verify outputs still exist
133136 for output in & entry. result . outputs {
@@ -152,11 +155,11 @@ impl Cache for FilesystemCache {
152155
153156 // Create parent directory
154157 if let Some ( parent) = path. parent ( ) {
155- tokio:: fs:: create_dir_all ( parent) . await . map_err ( |e| {
156- ConflowError :: CacheError {
158+ tokio:: fs:: create_dir_all ( parent)
159+ . await
160+ . map_err ( |e| ConflowError :: CacheError {
157161 message : format ! ( "Failed to create cache directory: {}" , e) ,
158- }
159- } ) ?;
162+ } ) ?;
160163 }
161164
162165 let entry = CachedEntry {
@@ -170,9 +173,11 @@ impl Cache for FilesystemCache {
170173 message : format ! ( "Failed to serialize cache entry: {}" , e) ,
171174 } ) ?;
172175
173- tokio:: fs:: write ( & path, json) . await . map_err ( |e| ConflowError :: CacheError {
174- message : format ! ( "Failed to write cache entry: {}" , e) ,
175- } ) ?;
176+ tokio:: fs:: write ( & path, json)
177+ . await
178+ . map_err ( |e| ConflowError :: CacheError {
179+ message : format ! ( "Failed to write cache entry: {}" , e) ,
180+ } ) ?;
176181
177182 Ok ( ( ) )
178183 }
@@ -182,29 +187,29 @@ impl Cache for FilesystemCache {
182187 let path = self . cache_path ( & key) ;
183188
184189 if path. exists ( ) {
185- tokio:: fs:: remove_file ( & path) . await . map_err ( |e| {
186- ConflowError :: CacheError {
190+ tokio:: fs:: remove_file ( & path)
191+ . await
192+ . map_err ( |e| ConflowError :: CacheError {
187193 message : format ! ( "Failed to remove cache entry: {}" , e) ,
188- }
189- } ) ?;
194+ } ) ?;
190195 }
191196
192197 Ok ( ( ) )
193198 }
194199
195200 async fn clear ( & self ) -> Result < ( ) , ConflowError > {
196201 if self . cache_dir . exists ( ) {
197- tokio:: fs:: remove_dir_all ( & self . cache_dir ) . await . map_err ( |e| {
198- ConflowError :: CacheError {
202+ tokio:: fs:: remove_dir_all ( & self . cache_dir )
203+ . await
204+ . map_err ( |e| ConflowError :: CacheError {
199205 message : format ! ( "Failed to clear cache: {}" , e) ,
200- }
201- } ) ?;
206+ } ) ?;
202207
203- tokio:: fs:: create_dir_all ( & self . cache_dir ) . await . map_err ( |e| {
204- ConflowError :: CacheError {
208+ tokio:: fs:: create_dir_all ( & self . cache_dir )
209+ . await
210+ . map_err ( |e| ConflowError :: CacheError {
205211 message : format ! ( "Failed to recreate cache directory: {}" , e) ,
206- }
207- } ) ?;
212+ } ) ?;
208213 }
209214
210215 Ok ( ( ) )
0 commit comments