wtf
This commit is contained in:
		
							parent
							
								
									b8e544bca8
								
							
						
					
					
						commit
						0f641db567
					
				@ -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
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user