File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,21 @@ pub(crate) struct ArtifactCache {
36
36
37
37
impl ArtifactCache {
38
38
pub ( crate ) fn new ( cache_dir : PathBuf ) -> Result < Self > {
39
- Ok ( Self { cache_dir } )
39
+ let cache = Self { cache_dir } ;
40
+ cache. ensure_cache_exists ( ) ?;
41
+ Ok ( cache)
40
42
}
41
43
42
44
pub ( crate ) fn purge ( & self ) -> Result < ( ) > {
43
45
fs:: remove_dir_all ( & self . cache_dir ) ?;
46
+ self . ensure_cache_exists ( ) ?;
47
+ Ok ( ( ) )
48
+ }
49
+
50
+ fn ensure_cache_exists ( & self ) -> Result < ( ) > {
51
+ if !self . cache_dir . exists ( ) {
52
+ fs:: create_dir_all ( & self . cache_dir ) ?;
53
+ }
44
54
Ok ( ( ) )
45
55
}
46
56
@@ -168,6 +178,7 @@ impl ArtifactCache {
168
178
return Ok ( ( ) ) ;
169
179
}
170
180
181
+ self . ensure_cache_exists ( ) ?;
171
182
fs:: rename ( cache_dir, target_dir) . context ( "could not move cache directory to target" ) ?;
172
183
Ok ( ( ) )
173
184
}
@@ -182,6 +193,7 @@ impl ArtifactCache {
182
193
if cache_dir. exists ( ) {
183
194
fs:: remove_dir_all ( & cache_dir) ?;
184
195
}
196
+ self . ensure_cache_exists ( ) ?;
185
197
186
198
debug ! ( ?target_dir, ?cache_dir, "saving artifact cache" ) ;
187
199
fs:: rename ( & target_dir, & cache_dir) . context ( "could not move target directory to cache" ) ?;
You can’t perform that action at this time.
0 commit comments