Skip to content

Commit c19d7cc

Browse files
authored
Merge pull request #1581 from ksylvan/0705-custom-directory-creation-bug
Fix Custom Patterns Directory Creation Logic
2 parents 5900dac + bd0c5f7 commit c19d7cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/tools/custom_patterns/custom_patterns.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package custom_patterns
22

33
import (
4+
"fmt"
45
"os"
56
"path/filepath"
67
"strings"
@@ -44,10 +45,12 @@ func (o *CustomPatterns) configure() error {
4445
o.CustomPatternsDir.Value = absPath
4546
}
4647

47-
// Create the directory if it doesn't exist
48-
if err := os.MkdirAll(o.CustomPatternsDir.Value, 0755); err != nil {
49-
// If we can't create it, clear the value to avoid errors
50-
o.CustomPatternsDir.Value = ""
48+
// Check if directory exists, create only if it doesn't
49+
if _, err := os.Stat(o.CustomPatternsDir.Value); os.IsNotExist(err) {
50+
if err := os.MkdirAll(o.CustomPatternsDir.Value, 0755); err != nil {
51+
// Log the error but don't clear the value - let it persist in env file
52+
fmt.Printf("Warning: Could not create custom patterns directory %s: %v\n", o.CustomPatternsDir.Value, err)
53+
}
5154
}
5255
}
5356

0 commit comments

Comments
 (0)