From 10a1a1e05885e31e5e0e104c400241b5b06a483b Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Tue, 21 Oct 2025 22:09:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20duplicate=20CreateDir=20op?= =?UTF-8?q?eration=20in=20init=20planning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent duplicate CreateDir operations when rules directory is the same as config directory by checking if the directory creation has already been planned before adding another one. --- src/cli/init_cli.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cli/init_cli.rs b/src/cli/init_cli.rs index 454654d..e23e175 100644 --- a/src/cli/init_cli.rs +++ b/src/cli/init_cli.rs @@ -623,8 +623,12 @@ impl InitCli { operations: &mut Vec, rules_dir: &Path, ) -> Result<()> { - // Create rules directory if it doesn't exist and is different from config dir - if !rules_dir.exists() { + // Create rules directory if it doesn't exist and hasn't been planned already + let already_planned = operations.iter().any(|op| { + matches!(op, Operation::CreateDir { path, .. } if path == rules_dir) + }); + + if !rules_dir.exists() && !already_planned { operations.push(Operation::CreateDir { path: rules_dir.to_path_buf(), #[cfg(unix)]