Skip to content

Commit 516f287

Browse files
committed
fixup! fsutil: Explicit parent directory creation
1 parent e723ac2 commit 516f287

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

internal/deb/extract.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ func extractData(dataReader io.Reader, options *ExtractOptions) error {
187187
// the metadata, since the extracted content itself will also create
188188
// any missing directories unaccounted for in the options.
189189
err := fsutil.Create(&fsutil.CreateOptions{
190-
Path: filepath.Join(options.TargetDir, sourcePath),
191-
Mode: tarHeader.FileInfo().Mode(),
192-
MakeParentDirs: true,
190+
Path: filepath.Join(options.TargetDir, sourcePath),
191+
Mode: tarHeader.FileInfo().Mode(),
192+
MakeParents: true,
193193
})
194194
if err != nil {
195195
return err
@@ -228,11 +228,11 @@ func extractData(dataReader io.Reader, options *ExtractOptions) error {
228228
tarHeader.Mode = int64(extractInfo.Mode)
229229
}
230230
err := fsutil.Create(&fsutil.CreateOptions{
231-
Path: targetPath,
232-
Mode: tarHeader.FileInfo().Mode(),
233-
Data: pathReader,
234-
Link: tarHeader.Linkname,
235-
MakeParentDirs: true,
231+
Path: targetPath,
232+
Mode: tarHeader.FileInfo().Mode(),
233+
Data: pathReader,
234+
Link: tarHeader.Linkname,
235+
MakeParents: true,
236236
})
237237
if err != nil {
238238
return err

internal/fsutil/create.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import (
99
)
1010

1111
type CreateOptions struct {
12-
Path string
13-
Mode fs.FileMode
14-
Data io.Reader
15-
Link string
16-
MakeParentDirs bool
12+
Path string
13+
Mode fs.FileMode
14+
Data io.Reader
15+
Link string
16+
MakeParents bool
1717
}
1818

1919
// Creates file according to passed CreateOptions.
20-
// If o.MakeParentDirs is true, missing parent directories of o.Path are
20+
// If o.MakeParents is true, missing parent directories of o.Path are
2121
// created with permissions 0755.
2222
func Create(o *CreateOptions) error {
2323
var err error
24-
if o.MakeParentDirs {
24+
if o.MakeParents {
2525
if err := os.MkdirAll(filepath.Dir(o.Path), 0755); err != nil {
2626
return err
2727
}

internal/fsutil/create_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@ type createTest struct {
2020

2121
var createTests = []createTest{{
2222
options: fsutil.CreateOptions{
23-
Path: "foo/bar",
24-
Data: bytes.NewBufferString("data1"),
25-
Mode: 0444,
26-
MakeParentDirs: true,
23+
Path: "foo/bar",
24+
Data: bytes.NewBufferString("data1"),
25+
Mode: 0444,
26+
MakeParents: true,
2727
},
2828
result: map[string]string{
2929
"/foo/": "dir 0755",
3030
"/foo/bar": "file 0444 5b41362b",
3131
},
3232
}, {
3333
options: fsutil.CreateOptions{
34-
Path: "foo/bar",
35-
Link: "../baz",
36-
Mode: fs.ModeSymlink,
37-
MakeParentDirs: true,
34+
Path: "foo/bar",
35+
Link: "../baz",
36+
Mode: fs.ModeSymlink,
37+
MakeParents: true,
3838
},
3939
result: map[string]string{
4040
"/foo/": "dir 0755",
4141
"/foo/bar": "symlink ../baz",
4242
},
4343
}, {
4444
options: fsutil.CreateOptions{
45-
Path: "foo/bar",
46-
Mode: fs.ModeDir | 0444,
47-
MakeParentDirs: true,
45+
Path: "foo/bar",
46+
Mode: fs.ModeDir | 0444,
47+
MakeParents: true,
4848
},
4949
result: map[string]string{
5050
"/foo/": "dir 0755",
@@ -56,7 +56,7 @@ var createTests = []createTest{{
5656
Mode: fs.ModeDir | fs.ModeSticky | 0775,
5757
},
5858
result: map[string]string{
59-
"/tmp/": "dir 01775",
59+
"/tmp/": "dir 01775",
6060
},
6161
}, {
6262
options: fsutil.CreateOptions{

internal/setup/fetch.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func FetchRelease(options *FetchOptions) (*Release, error) {
3838
cacheDir = cache.DefaultDir("chisel")
3939
}
4040

41-
dirName := filepath.Join(cacheDir, "releases", options.Label+"-"+options.Version)
41+
dirName := filepath.Join(cacheDir, "releases", options.Label + "-" + options.Version)
4242
err := os.MkdirAll(dirName, 0755)
4343
if err == nil {
4444
lockFile := fslock.New(filepath.Join(cacheDir, "releases", ".lock"))
@@ -57,7 +57,7 @@ func FetchRelease(options *FetchOptions) (*Release, error) {
5757
return nil, err
5858
}
5959

60-
req, err := http.NewRequest("GET", baseURL+options.Label+"-"+options.Version, nil)
60+
req, err := http.NewRequest("GET", baseURL + options.Label + "-" + options.Version, nil)
6161
if err != nil {
6262
return nil, fmt.Errorf("cannot create request for release information: %w", err)
6363
}
@@ -139,11 +139,11 @@ func extractTar(dataReader io.Reader, targetDir string) error {
139139
//debugf("Extracting header: %#v", tarHeader)
140140

141141
err = fsutil.Create(&fsutil.CreateOptions{
142-
Path: filepath.Join(targetDir, sourcePath),
143-
Mode: tarHeader.FileInfo().Mode(),
144-
Data: tarReader,
145-
Link: tarHeader.Linkname,
146-
MakeParentDirs: true,
142+
Path: filepath.Join(targetDir, sourcePath),
143+
Mode: tarHeader.FileInfo().Mode(),
144+
Data: tarReader,
145+
Link: tarHeader.Linkname,
146+
MakeParents: true,
147147
})
148148
if err != nil {
149149
return err

internal/slicer/slicer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ func Run(options *RunOptions) error {
212212
}
213213

214214
err := fsutil.Create(&fsutil.CreateOptions{
215-
Path: targetPath,
216-
Mode: tarHeader.FileInfo().Mode(),
217-
Data: fileContent,
218-
Link: linkTarget,
219-
MakeParentDirs: true,
215+
Path: targetPath,
216+
Mode: tarHeader.FileInfo().Mode(),
217+
Data: fileContent,
218+
Link: linkTarget,
219+
MakeParents: true,
220220
})
221221
if err != nil {
222222
return err

0 commit comments

Comments
 (0)