31 lines
1.0 KiB
Diff
31 lines
1.0 KiB
Diff
From d882aa4202dec390cb8b9683e974b9705b4c19eb Mon Sep 17 00:00:00 2001
|
|
From: Yuhang Wei <weiyuhang3@huawei.com>
|
|
Date: Tue, 3 Dec 2024 11:01:56 +0800
|
|
Subject: [PATCH 11/11] fix(kbimg): prevent concurrent execution by checking a
|
|
lock file
|
|
|
|
Signed-off-by: Yuhang Wei <weiyuhang3@huawei.com>
|
|
---
|
|
KubeOS-Rust/kbimg/src/main.rs | 5 +++++
|
|
1 file changed, 5 insertions(+)
|
|
|
|
diff --git a/KubeOS-Rust/kbimg/src/main.rs b/KubeOS-Rust/kbimg/src/main.rs
|
|
index 8639f81f..43e9d422 100644
|
|
--- a/KubeOS-Rust/kbimg/src/main.rs
|
|
+++ b/KubeOS-Rust/kbimg/src/main.rs
|
|
@@ -40,6 +40,11 @@ trait CreateImage {
|
|
|
|
fn process(info: Box<dyn CreateImage>, mut config: Config, debug: bool) -> Result<()> {
|
|
let dir = PathBuf::from(SCRIPTS_DIR);
|
|
+ let lock = dir.join("test.lock");
|
|
+ if lock.exists() {
|
|
+ error!("It looks like another kbimg process is running. Please wait it to finish.");
|
|
+ exit(1);
|
|
+ }
|
|
if dir.exists() {
|
|
debug!("Removing existing scripts directory");
|
|
fs::remove_dir_all(&dir)?;
|
|
--
|
|
2.39.5 (Apple Git-154)
|
|
|