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