File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -53,21 +53,29 @@ impl Cwd {
5353 }
5454
5555 tokio:: task:: spawn_blocking ( move || {
56- let path = CWD . path ( ) ;
57- std:: fs:: create_dir_all ( & path) . ok ( ) ;
56+ let path = CWD . ensure_cache ( ) ;
5857
5958 _ = set_current_dir ( & path) ;
6059 let cur = current_dir ( ) . unwrap_or_default ( ) ;
6160
6261 unsafe { std:: env:: set_var ( "PWD" , path) }
6362 SYNCING . store ( false , Ordering :: Relaxed ) ;
6463
65- let path = CWD . path ( ) ;
64+ let path = CWD . ensure_cache ( ) ;
6665 if cur != path {
67- std:: fs:: create_dir_all ( & path) . ok ( ) ;
6866 set_current_dir ( & path) . ok ( ) ;
6967 unsafe { std:: env:: set_var ( "PWD" , path) }
7068 }
7169 } ) ;
7270 }
71+
72+ fn ensure_cache ( & self ) -> PathBuf {
73+ let url = self . 0 . load ( ) ;
74+ if let Some ( p) = provider:: cache ( url. as_ref ( ) ) {
75+ std:: fs:: create_dir_all ( & p) . ok ( ) ;
76+ p
77+ } else {
78+ url. loc . to_path ( )
79+ }
80+ }
7381}
You can’t perform that action at this time.
0 commit comments