diff --git a/internal/archive/archive_test.go b/internal/archive/archive_test.go index ac94088d..0a72a419 100644 --- a/internal/archive/archive_test.go +++ b/internal/archive/archive_test.go @@ -501,7 +501,7 @@ func (s *S) testOpenArchiveArch(c *C, release ubuntuRelease, arch string) { {Path: "/hostname"}, }, }, - FileCreator: fsutil.NewFileCreator(), + FileCreator: fsutil.NewCreator(), }) c.Assert(err, IsNil) diff --git a/internal/deb/extract.go b/internal/deb/extract.go index 1985d219..9b0d093f 100644 --- a/internal/deb/extract.go +++ b/internal/deb/extract.go @@ -25,7 +25,7 @@ type ExtractOptions struct { TargetDir string Extract map[string][]ExtractInfo Globbed map[string][]string - FileCreator *fsutil.FileCreator + FileCreator *fsutil.Creator } type ExtractInfo struct { diff --git a/internal/deb/extract_test.go b/internal/deb/extract_test.go index d9107103..69cb400b 100644 --- a/internal/deb/extract_test.go +++ b/internal/deb/extract_test.go @@ -291,7 +291,7 @@ func (s *S) TestExtract(c *C) { options := test.options options.Package = "base-files" options.TargetDir = dir - options.FileCreator = fsutil.NewFileCreator() + options.FileCreator = fsutil.NewCreator() if test.globbed != nil { options.Globbed = make(map[string][]string) diff --git a/internal/fsutil/create.go b/internal/fsutil/create.go index dc5a603a..d0f31c93 100644 --- a/internal/fsutil/create.go +++ b/internal/fsutil/create.go @@ -21,7 +21,7 @@ type CreateOptions struct { MakeParents bool } -type FileInfo struct { +type Info struct { Path string Mode fs.FileMode Hash string @@ -29,18 +29,18 @@ type FileInfo struct { Link string } -type FileCreator struct { - // Files keeps track of information about the files created. If a file +type Creator struct { + // Created keeps track of information about the files created. If a file // is created several times it only tracks the latest one. - Files map[string]FileInfo + Created map[string]Info } -func NewFileCreator() *FileCreator { - return &FileCreator{Files: make(map[string]FileInfo)} +func NewCreator() *Creator { + return &Creator{Created: make(map[string]Info)} } // Creates a filesystem entry according to the provided options. -func (fc FileCreator) Create(o *CreateOptions) error { +func (fc Creator) Create(o *CreateOptions) error { rp := readerProxy{inner: o.Data, h: sha256.New()} o.Data = &rp @@ -64,14 +64,14 @@ func (fc FileCreator) Create(o *CreateOptions) error { return err } - fr := FileInfo{ + fr := Info{ Path: o.Path, Mode: o.Mode, Hash: hex.EncodeToString(rp.h.Sum(nil)), Size: rp.size, Link: o.Link, } - fc.Files[o.Path] = fr + fc.Created[o.Path] = fr return nil } diff --git a/internal/fsutil/create_test.go b/internal/fsutil/create_test.go index 077dfa8b..00d9ccf5 100644 --- a/internal/fsutil/create_test.go +++ b/internal/fsutil/create_test.go @@ -83,7 +83,7 @@ func (s *S) TestCreate(c *C) { dir := c.MkDir() options := test.options options.Path = filepath.Join(dir, options.Path) - fileCreator := fsutil.NewFileCreator() + fileCreator := fsutil.NewCreator() err := fileCreator.Create(&options) if test.error != "" { c.Assert(err, ErrorMatches, test.error) @@ -103,9 +103,9 @@ func (s *S) TestCreate(c *C) { } } -func treeDumpFileCreator(fc *fsutil.FileCreator, root string) map[string]string { +func treeDumpFileCreator(fc *fsutil.Creator, root string) map[string]string { result := make(map[string]string) - for _, file := range fc.Files { + for _, file := range fc.Created { path := strings.TrimPrefix(file.Path, root) fperm := file.Mode.Perm() if file.Mode&fs.ModeSticky != 0 { diff --git a/internal/setup/fetch.go b/internal/setup/fetch.go index 41e41aaf..b34584a5 100644 --- a/internal/setup/fetch.go +++ b/internal/setup/fetch.go @@ -137,7 +137,7 @@ func extractTar(dataReader io.Reader, targetDir string) error { //debugf("Extracting header: %#v", tarHeader) - err = fsutil.NewFileCreator().Create(&fsutil.CreateOptions{ + err = fsutil.NewCreator().Create(&fsutil.CreateOptions{ Path: filepath.Join(targetDir, sourcePath), Mode: tarHeader.FileInfo().Mode(), Data: tarReader, diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 4561ac9e..b44a4123 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -28,7 +28,6 @@ func Run(options *RunOptions) error { archives := make(map[string]archive.Archive) extract := make(map[string]map[string][]deb.ExtractInfo) pathInfos := make(map[string]setup.PathInfo) - knownPaths := make(map[string]bool) knownPaths["/"] = true @@ -154,7 +153,7 @@ func Run(options *RunOptions) error { if reader == nil { continue } - fileCreator := fsutil.NewFileCreator() + fileCreator := fsutil.NewCreator() err := deb.Extract(reader, &deb.ExtractOptions{ Package: slice.Package, Extract: extract[slice.Package], @@ -214,7 +213,7 @@ func Run(options *RunOptions) error { return fmt.Errorf("internal error: cannot extract path of kind %q", pathInfo.Kind) } - fileCreator := fsutil.NewFileCreator() + fileCreator := fsutil.NewCreator() err := fileCreator.Create(&fsutil.CreateOptions{ Path: targetPath, Mode: tarHeader.FileInfo().Mode(),