Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/splunk/enterprise/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ func createAppDownloadDir(ctx context.Context, path string) error {
scopedLog.Error(errDir, "Unable to create directory at path")
return errDir
}
} else if err != nil {
scopedLog.Error(err, "Unable to access path")
Copy link
Copy Markdown
Collaborator

@kubabuczak kubabuczak Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Why log it here? Shouldn't the calling function log it?

return err
}
return nil
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Wouldn't this be better?

_, err := os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
	return os.MkdirAll(path, 0700)
}
return err

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And just leave logging to caller

Expand Down
9 changes: 8 additions & 1 deletion pkg/splunk/enterprise/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

//"io"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -1196,7 +1197,13 @@ func TestCreateAppDownloadDir(t *testing.T) {
t.Errorf("Didn't expect error")
}

err = createAppDownloadDir(ctx, "/xyzzz.txt")
blockerFile, err := os.CreateTemp(t.TempDir(), "app-download-dir-blocker")
if err != nil {
t.Fatalf("failed to create blocker file: %v", err)
}
defer blockerFile.Close()

err = createAppDownloadDir(ctx, filepath.Join(blockerFile.Name(), "child"))
if err == nil {
t.Errorf("Expected error")
}
Expand Down
Loading