🐛 Fix duplicate CreateDir operation in init planning
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.
This commit is contained in:
committed by
Jeremiah Russell
parent
d4cc2621db
commit
10a1a1e058
@@ -623,8 +623,12 @@ impl InitCli {
|
||||
operations: &mut Vec<Operation>,
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user