Skip to content

Commit

Permalink
cmd/runner: fix --result permission issue
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <weifu@microsoft.com>
  • Loading branch information
fuweid committed Jan 5, 2024
1 parent 4487bbd commit d5c9e99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/kperf/commands/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,16 @@ var runCommand = cli.Command{

var f *os.File = os.Stdout
if outputFilePath != "" {
err := os.MkdirAll(filepath.Dir(outputFilePath), 0600)
outputFileDir := filepath.Dir(outputFilePath)

_, err = os.Stat(outputFileDir)
if err != nil && os.IsNotExist(err) {
err = os.MkdirAll(outputFileDir, 0750)
}
if err != nil {
return err
return fmt.Errorf("failed to ensure output's dir %s: %w", outputFileDir, err)
}

f, err = os.Create(outputFilePath)
if err != nil {
return err
Expand Down

0 comments on commit d5c9e99

Please sign in to comment.