diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-12-18 17:41:15 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-12-18 19:51:26 +0100 |
commit | 8adba648cc130a97d2c814c65aa8396044c251fd (patch) | |
tree | 95415853e28ee83e0342cc55944f3bc16d746f4f /hugofs | |
parent | 6f13430d4a3b0d8b196f13958fbfb6478be1f3aa (diff) | |
download | hugo-8adba648cc130a97d2c814c65aa8396044c251fd.tar.gz hugo-8adba648cc130a97d2c814c65aa8396044c251fd.zip |
all: Remove unused code
Using x/tools/cmd/deadcode
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/fileinfo.go | 13 | ||||
-rw-r--r-- | hugofs/filename_filter_fs.go | 12 | ||||
-rw-r--r-- | hugofs/fs.go | 13 | ||||
-rw-r--r-- | hugofs/fs_test.go | 3 |
4 files changed, 9 insertions, 32 deletions
diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go index c33997278..773352ea8 100644 --- a/hugofs/fileinfo.go +++ b/hugofs/fileinfo.go @@ -15,6 +15,7 @@ package hugofs import ( + "errors" "os" "path/filepath" "reflect" @@ -28,8 +29,6 @@ import ( "github.com/gohugoio/hugo/hugofs/files" "golang.org/x/text/unicode/norm" - "errors" - "github.com/gohugoio/hugo/common/hreflect" "github.com/gohugoio/hugo/common/htime" @@ -224,7 +223,8 @@ func newDirNameOnlyFileInfo(name string, meta *FileMeta, fileOpener func() (afer func decorateFileInfo( fi os.FileInfo, fs afero.Fs, opener func() (afero.File, error), - filename, filepath string, inMeta *FileMeta) FileMetaInfo { + filename, filepath string, inMeta *FileMeta, +) FileMetaInfo { var meta *FileMeta var fim FileMetaInfo @@ -289,13 +289,6 @@ func fileInfosToNames(fis []os.FileInfo) []string { return names } -func fromSlash(filenames []string) []string { - for i, name := range filenames { - filenames[i] = filepath.FromSlash(name) - } - return filenames -} - func sortFileInfos(fis []os.FileInfo) { sort.Slice(fis, func(i, j int) bool { fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo) diff --git a/hugofs/filename_filter_fs.go b/hugofs/filename_filter_fs.go index 4ecd1f55a..c101309c2 100644 --- a/hugofs/filename_filter_fs.go +++ b/hugofs/filename_filter_fs.go @@ -23,9 +23,7 @@ import ( "github.com/spf13/afero" ) -var ( - _ FilesystemUnwrapper = (*filenameFilterFs)(nil) -) +var _ FilesystemUnwrapper = (*filenameFilterFs)(nil) func newFilenameFilterFs(fs afero.Fs, base string, filter *glob.FilenameFilter) afero.Fs { return &filenameFilterFs{ @@ -93,12 +91,6 @@ func (fs *filenameFilterFs) Stat(name string) (os.FileInfo, error) { return fi, err } -func (fs *filenameFilterFs) getOpener(name string) func() (afero.File, error) { - return func() (afero.File, error) { - return fs.Open(name) - } -} - type filenameFilterDir struct { afero.File base string @@ -162,9 +154,11 @@ func (fs *filenameFilterFs) RemoveAll(p string) error { func (fs *filenameFilterFs) Rename(o, n string) error { return syscall.EPERM } + func (fs *filenameFilterFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } + func (fs *filenameFilterFs) Name() string { return "FinameFilterFS" } diff --git a/hugofs/fs.go b/hugofs/fs.go index 9462afa24..5b8a3adb2 100644 --- a/hugofs/fs.go +++ b/hugofs/fs.go @@ -60,14 +60,7 @@ type Fs struct { WorkingDirWritable afero.Fs } -// NewDefault creates a new Fs with the OS file system -// as source and destination file systems. -func NewDefault(conf config.BaseConfig) *Fs { - fs := Os - return NewFrom(fs, conf) -} - -func NewDefaultOld(cfg config.Provider) *Fs { +func NewDefault(cfg config.Provider) *Fs { workingDir, publishDir := getWorkingPublishDir(cfg) fs := Os return newFs(fs, fs, workingDir, publishDir) @@ -99,7 +92,6 @@ func getWorkingPublishDir(cfg config.Provider) (string, string) { publishDir = cfg.GetString("publishDir") } return workingDir, publishDir - } func newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs { @@ -166,7 +158,7 @@ func MakeReadableAndRemoveAllModulePkgDir(fs afero.Fs, dir string) (int, error) } if info.IsDir() { counter++ - fs.Chmod(path, 0777) + fs.Chmod(path, 0o777) } return nil }) @@ -217,7 +209,6 @@ func WalkFilesystems(fs afero.Fs, fn WalkFn) bool { if WalkFilesystems(afs.UnwrapFilesystem(), fn) { return true } - } else if bfs, ok := fs.(FilesystemsUnwrapper); ok { for _, sf := range bfs.UnwrapFilesystems() { if WalkFilesystems(sf, fn) { diff --git a/hugofs/fs_test.go b/hugofs/fs_test.go index 509aca62f..b2ed2e86e 100644 --- a/hugofs/fs_test.go +++ b/hugofs/fs_test.go @@ -30,7 +30,6 @@ func TestIsOsFs(t *testing.T) { c.Assert(IsOsFs(&afero.MemMapFs{}), qt.Equals, false) c.Assert(IsOsFs(afero.NewBasePathFs(&afero.MemMapFs{}, "/public")), qt.Equals, false) c.Assert(IsOsFs(afero.NewBasePathFs(Os, t.TempDir())), qt.Equals, true) - } func TestNewDefault(t *testing.T) { @@ -38,7 +37,7 @@ func TestNewDefault(t *testing.T) { v := config.New() v.Set("workingDir", t.TempDir()) v.Set("publishDir", "public") - f := NewDefaultOld(v) + f := NewDefault(v) c.Assert(f.Source, qt.IsNotNil) c.Assert(f.Source, hqt.IsSameType, new(afero.OsFs)) |