wtf
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jeffrey Paul 2022-12-02 02:05:09 +01:00
parent b8e544bca8
commit 0f641db567

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"strings"
"github.com/spf13/afero" "github.com/spf13/afero"
) )
@ -16,6 +17,7 @@ type ManifestFile struct {
type Manifest struct { type Manifest struct {
SourceFS afero.Fs SourceFS afero.Fs
Files []*ManifestFile Files []*ManifestFile
ScanOptions *ManifestScanOptions
TotalFileSize int64 TotalFileSize int64
} }
@ -31,7 +33,8 @@ func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, err
func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) { func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) {
m := &Manifest{ m := &Manifest{
SourceFS: fs, SourceFS: fs,
ScanOptions: options,
} }
m.Scan() m.Scan()
return m, nil return m, nil
@ -40,6 +43,11 @@ func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, er
func (m *Manifest) Scan() { func (m *Manifest) Scan() {
afero.Walk(m.SourceFS, "", func(path string, info fs.FileInfo, err error) error { 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() { if info != nil && info.IsDir() {
// manifests contain only files, directories are implied. // manifests contain only files, directories are implied.
return nil return nil
@ -57,6 +65,8 @@ func (m *Manifest) Scan() {
} }
m.Files = append(m.Files, nf) m.Files = append(m.Files, nf)
m.TotalFileSize = m.TotalFileSize + info.Size() 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 return nil
}) })
} }