File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,18 @@ impl Credentials {
6464 pub fn save ( client_name : & str , token : Token ) -> Result < ( ) > {
6565 let credentials_path = Self :: get_credentials_path ( client_name) ?;
6666
67- file_util:: lock!( & credentials_path) ;
67+ if credentials_path. exists ( ) {
68+ // waiting for any other process working with the file to finish
69+ file_util:: lock!( & credentials_path) ;
70+ }
6871
6972 if let Some ( p) = credentials_path. parent ( ) {
7073 fs:: create_dir_all ( p)
7174 . with_context ( || format ! ( "Failed to create directory {}" , p. display( ) ) ) ?;
7275 }
7376 let credentials_file = File :: create ( & credentials_path)
7477 . with_context ( || format ! ( "Failed to create file at {}" , credentials_path. display( ) ) ) ?;
78+ file_util:: lock!( & credentials_path) ;
7579
7680 // write token
7781 if let Err ( e) = serde_json:: to_writer ( credentials_file, & token) {
You can’t perform that action at this time.
0 commit comments