From 39435f913b0f2c7d451f7e6876689ca8900c6a28 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Thu, 23 Sep 2021 15:37:34 -0600 Subject: [PATCH 1/3] exclusive lock on cookie file --- appmgr/src/context/cli.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appmgr/src/context/cli.rs b/appmgr/src/context/cli.rs index 4f965cf6f..59468b049 100644 --- a/appmgr/src/context/cli.rs +++ b/appmgr/src/context/cli.rs @@ -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(); From 99a0ec7ff5ffc96f7d80cef1b4fb95a7064434d8 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Thu, 23 Sep 2021 15:59:27 -0600 Subject: [PATCH 2/3] fix build issue --- appmgr/src/context/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appmgr/src/context/cli.rs b/appmgr/src/context/cli.rs index 59468b049..a19542a0a 100644 --- a/appmgr/src/context/cli.rs +++ b/appmgr/src/context/cli.rs @@ -45,7 +45,7 @@ impl Drop for CliContextSeed { 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(); From 61ed0a8a581111de65b8ef453a262f7ce76c3d44 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Thu, 23 Sep 2021 16:21:41 -0600 Subject: [PATCH 3/3] fixes build issues --- appmgr/src/context/cli.rs | 5 +++-- appmgr/src/db/mod.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/appmgr/src/context/cli.rs b/appmgr/src/context/cli.rs index a19542a0a..4519d27a5 100644 --- a/appmgr/src/context/cli.rs +++ b/appmgr/src/context/cli.rs @@ -45,9 +45,10 @@ impl Drop for CliContextSeed { File::create(&tmp).unwrap(), fd_lock_rs::LockType::Exclusive, true, - )?; + ) + .unwrap(); let store = self.cookie_store.lock().unwrap(); - store.save_json(&mut writer).unwrap(); + store.save_json(&mut *writer).unwrap(); writer.sync_all().unwrap(); std::fs::rename(tmp, &self.cookie_path).unwrap(); } diff --git a/appmgr/src/db/mod.rs b/appmgr/src/db/mod.rs index 94c720b19..ac6fca35e 100644 --- a/appmgr/src/db/mod.rs +++ b/appmgr/src/db/mod.rs @@ -193,6 +193,6 @@ pub async fn ui( let ptr = "/ui".parse::()? + &pointer; Ok(WithRevision { response: (), - revision: Some(ctx.db.put(&ptr, &value, None).await?), + revision: ctx.db.put(&ptr, &value, None).await?, }) }