From 0f641db567103af6cbd6155a29de6cfdfbfed262 Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 2 Dec 2022 02:05:09 +0100 Subject: [PATCH] wtf --- mfer/manifest.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mfer/manifest.go b/mfer/manifest.go index cf4071c..bc06af7 100644 --- a/mfer/manifest.go +++ b/mfer/manifest.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "io/fs" + "strings" "github.com/spf13/afero" ) @@ -16,6 +17,7 @@ type ManifestFile struct { type Manifest struct { SourceFS afero.Fs Files []*ManifestFile + ScanOptions *ManifestScanOptions TotalFileSize int64 } @@ -31,7 +33,8 @@ func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, err func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) { m := &Manifest{ - SourceFS: fs, + SourceFS: fs, + ScanOptions: options, } m.Scan() return m, nil @@ -40,6 +43,11 @@ func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, er func (m *Manifest) Scan() { afero.Walk(m.SourceFS, "", func(path string, info fs.FileInfo, err error) error { + if m.ScanOptions.IgnoreDotfiles && strings.HasPrefix(path, ".") { + // FIXME make this check all path components BUG + return nil + } + if info != nil && info.IsDir() { // manifests contain only files, directories are implied. return nil @@ -57,6 +65,8 @@ func (m *Manifest) Scan() { } m.Files = append(m.Files, nf) m.TotalFileSize = m.TotalFileSize + info.Size() + fmt.Printf("total file count now %i\n", len(m.Files)) + fmt.Printf("total file size now %i\n", m.TotalFileSize) return nil }) }