Skip to content

Commit

Permalink
more naming simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Jan 16, 2024
1 parent 3b5bb4a commit 13d4b06
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions internal/fsutil/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewCreator() *Creator {
}

// Creates a filesystem entry according to the provided options.
func (fc Creator) Create(o *CreateOptions) error {
func (c Creator) Create(o *CreateOptions) error {
rp := readerProxy{inner: o.Data, h: sha256.New()}
o.Data = &rp

Expand Down Expand Up @@ -71,7 +71,7 @@ func (fc Creator) Create(o *CreateOptions) error {
Size: rp.size,
Link: o.Link,
}
fc.Created[o.Path] = fr
c.Created[o.Path] = fr
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions internal/fsutil/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ func (s *S) TestCreate(c *C) {
dir := c.MkDir()
options := test.options
options.Path = filepath.Join(dir, options.Path)
fileCreator := fsutil.NewCreator()
err := fileCreator.Create(&options)
fsCreator := fsutil.NewCreator()
err := fsCreator.Create(&options)
if test.error != "" {
c.Assert(err, ErrorMatches, test.error)
} else {
c.Assert(err, IsNil)
}
c.Assert(testutil.TreeDump(dir), DeepEquals, test.result)
if test.options.MakeParents {
// The fileCreator does not record the parent directories created
// The fsCreator does not record the parent directories created
// implicitly.
for path, info := range treeDumpFileCreator(fileCreator, dir) {
for path, info := range treeDumpFSCreator(fsCreator, dir) {
c.Assert(info, Equals, test.result[path])
}
} else {
c.Assert(treeDumpFileCreator(fileCreator, dir), DeepEquals, test.result)
c.Assert(treeDumpFSCreator(fsCreator, dir), DeepEquals, test.result)
}
}
}

func treeDumpFileCreator(fc *fsutil.Creator, root string) map[string]string {
func treeDumpFSCreator(cr *fsutil.Creator, root string) map[string]string {
result := make(map[string]string)
for _, file := range fc.Created {
for _, file := range cr.Created {
path := strings.TrimPrefix(file.Path, root)
fperm := file.Mode.Perm()
if file.Mode&fs.ModeSticky != 0 {
Expand Down
8 changes: 4 additions & 4 deletions internal/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ func Run(options *RunOptions) error {
if reader == nil {
continue
}
fileCreator := fsutil.NewCreator()
fsCreator := fsutil.NewCreator()
err := deb.Extract(reader, &deb.ExtractOptions{
Package: slice.Package,
Extract: extract[slice.Package],
TargetDir: targetDir,
Globbed: globbedPaths,
FSCreator: fileCreator,
FSCreator: fsCreator,
})
reader.Close()
packages[slice.Package] = nil
Expand Down Expand Up @@ -213,8 +213,8 @@ func Run(options *RunOptions) error {
return fmt.Errorf("internal error: cannot extract path of kind %q", pathInfo.Kind)
}

fileCreator := fsutil.NewCreator()
err := fileCreator.Create(&fsutil.CreateOptions{
fsCreator := fsutil.NewCreator()
err := fsCreator.Create(&fsutil.CreateOptions{
Path: targetPath,
Mode: tarHeader.FileInfo().Mode(),
Data: fileContent,
Expand Down

0 comments on commit 13d4b06

Please sign in to comment.