rollup from next branch #4

Merged
sneak merged 10 commits from next into master 2022-12-04 07:59:37 +00:00
1 changed files with 11 additions and 1 deletions
Showing only changes of commit 0f641db567 - Show all commits

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
}) })
} }