Skip to content

Commit 69f24f0

Browse files
authored
chore(refactor): use new root.Mkdirall (#24298)
Signed-off-by: Michael Crenshaw <[email protected]>
1 parent 7168674 commit 69f24f0

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

commitserver/commit/hydratorhelper.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package commit
22

33
import (
44
"encoding/json"
5-
"errors"
65
"fmt"
7-
"io/fs"
86
"os"
97
"path/filepath"
108
"strings"
@@ -73,7 +71,7 @@ func WriteForPaths(root *os.Root, repoUrl, drySha string, dryCommitMetadata *app
7371
hydratePath = ""
7472
}
7573

76-
err = mkdirAll(root, hydratePath)
74+
err = root.MkdirAll(hydratePath, 0o755)
7775
if err != nil {
7876
return fmt.Errorf("failed to create path: %w", err)
7977
}
@@ -212,25 +210,3 @@ func writeManifests(root *os.Root, dirPath string, manifests []*apiclient.Hydrat
212210

213211
return nil
214212
}
215-
216-
// mkdirAll creates the directory and all its parents if they do not exist. It returns an error if the directory
217-
// cannot be.
218-
func mkdirAll(root *os.Root, dirPath string) error {
219-
parts := strings.Split(dirPath, string(os.PathSeparator))
220-
builtPath := ""
221-
for _, part := range parts {
222-
if part == "" {
223-
continue
224-
}
225-
builtPath = filepath.Join(builtPath, part)
226-
err := root.Mkdir(builtPath, os.ModePerm)
227-
if err != nil {
228-
if errors.Is(err, fs.ErrExist) {
229-
log.WithError(err).Warnf("path %s already exists, skipping", dirPath)
230-
continue
231-
}
232-
return fmt.Errorf("failed to create path: %w", err)
233-
}
234-
}
235-
return nil
236-
}

0 commit comments

Comments
 (0)