diff --git a/aw-client-rust/src/single_instance.rs b/aw-client-rust/src/single_instance.rs
index 745fa2b2..985da131 100644
--- a/aw-client-rust/src/single_instance.rs
+++ b/aw-client-rust/src/single_instance.rs
@@ -1,6 +1,6 @@
use dirs::cache_dir;
use fs4::fs_std::FileExt;
-use log::{debug, error};
+use log::debug;
use std::fs::{File, OpenOptions};
use std::io;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -48,7 +48,8 @@ impl SingleInstance {
locked: Arc::new(AtomicBool::new(true)),
}),
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {
- error!("Another instance is already running");
+ // Qualified so the unix build doesn't carry an unused `error` import
+ log::error!("Another instance is already running");
Err(SingleInstanceError::AlreadyRunning)
}
Err(e) => Err(SingleInstanceError::Io(e)),
@@ -58,7 +59,12 @@ impl SingleInstance {
#[cfg(unix)]
{
// On Unix-like systems, use flock
- match OpenOptions::new().write(true).create(true).open(&lockfile) {
+ match OpenOptions::new()
+ .write(true)
+ .create(true)
+ .truncate(true)
+ .open(&lockfile)
+ {
Ok(file) => match file.try_lock_exclusive() {
Ok(true) => Ok(SingleInstance {
file: Some(file),
diff --git a/aw-client-rust/tests/test.rs b/aw-client-rust/tests/test.rs
index 9b8928d2..d66d6566 100644
--- a/aw-client-rust/tests/test.rs
+++ b/aw-client-rust/tests/test.rs
@@ -91,7 +91,7 @@ mod test {
// Keep the listener alive until the server binds — prevents TOCTOU race in reserve_port
thread_local! {
- static RESERVED_PORT: RefCell