@@ -173,7 +173,7 @@ impl SccacheClient {
173173 ) ;
174174 }
175175
176- pub fn clear_disk_cache ( & self ) -> sccache:: errors:: Result < ( ) > {
176+ pub fn clear_disk_cache ( & self ) -> sccache:: errors:: Result < PathBuf > {
177177 self . zero_stats ( ) ;
178178 let disk_cache = ( || {
179179 if let Some ( cfg_path_idx) = self . envvars . iter ( ) . position ( |( k, _) | k == "SCCACHE_CONF" ) {
@@ -191,10 +191,10 @@ impl SccacheClient {
191191 } ) ( ) ;
192192 println ! ( "clear_disk_cache: {:?}" , disk_cache. dir) ;
193193 fs:: remove_dir_all ( & disk_cache. dir ) ?;
194- Ok ( ( ) )
194+ Ok ( disk_cache . dir . clone ( ) )
195195 }
196196
197- pub fn clear_toolchains_cache ( & self ) -> sccache:: errors:: Result < ( ) > {
197+ pub fn clear_toolchains_cache ( & self ) -> sccache:: errors:: Result < PathBuf > {
198198 let dist_config = ( || {
199199 if let Some ( cfg_path_idx) = self . envvars . iter ( ) . position ( |( k, _) | k == "SCCACHE_CONF" ) {
200200 if let Some ( ( _, cfg_path) ) = self . envvars . get ( cfg_path_idx) {
@@ -207,9 +207,17 @@ impl SccacheClient {
207207 }
208208 DistConfig :: default ( )
209209 } ) ( ) ;
210- println ! ( "clear_toolchains_cache: {:?}" , dist_config. cache_dir) ;
211- fs:: remove_dir_all ( & dist_config. cache_dir ) ?;
212- Ok ( ( ) )
210+ let tc_dir = dist_config. cache_dir . join ( "client" ) . join ( "tc" ) ;
211+ println ! ( "clear_toolchains_cache: {:?}" , tc_dir) ;
212+ for entry in std:: fs:: read_dir ( & tc_dir) ? {
213+ let path = entry?. path ( ) ;
214+ if fs:: symlink_metadata ( & path) ?. is_dir ( ) {
215+ fs:: remove_dir_all ( & path) ?;
216+ } else {
217+ fs:: remove_file ( & path) ?;
218+ }
219+ }
220+ Ok ( tc_dir. clone ( ) )
213221 }
214222}
215223
0 commit comments