exclusive lock on cookie file

This commit is contained in:
Keagan McClelland
2021-09-23 15:37:34 -06:00
committed by Aiden McClelland
parent 6c91d3b7af
commit 0517e2d4e8

View File

@@ -41,7 +41,11 @@ pub struct CliContextSeed {
impl Drop for CliContextSeed {
fn drop(&mut self) {
let tmp = format!("{}.tmp", self.cookie_path.display());
let mut writer = File::create(&tmp).unwrap();
let mut writer = fd_lock_rs::FdLock::lock(
File::create(&tmp).unwrap(),
fd_lock_rs::LockType::Exclusive,
true,
);
let store = self.cookie_store.lock().unwrap();
store.save_json(&mut writer).unwrap();
writer.sync_all().unwrap();