Skip to content

Commit 65d44fd

Browse files
committed
fixed login lock
1 parent 0996325 commit 65d44fd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tmc-langs-cli/src/config/credentials.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
 (0)