works but has a weird bug
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2022-12-02 01:54:01 +01:00
parent 5c76824e14
commit b8e544bca8
697 changed files with 59 additions and 294367 deletions

View File

@@ -1,6 +1,7 @@
package mfer
import (
"fmt"
"io"
"io/fs"
@@ -13,16 +14,22 @@ type ManifestFile struct {
}
type Manifest struct {
SourceFS afero.Fs
Files []*ManifestFile
SourceFS afero.Fs
Files []*ManifestFile
TotalFileSize int64
}
func NewFromPath(inputPath string) (*Manifest, error) {
type ManifestScanOptions struct {
IgnoreDotfiles bool
FollowSymLinks bool
}
func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, error) {
afs := afero.NewBasePathFs(afero.NewOsFs(), inputPath)
return NewFromFilesystem(afs)
return NewFromFilesystem(afs, options)
}
func NewFromFilesystem(fs afero.Fs) (*Manifest, error) {
func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) {
m := &Manifest{
SourceFS: fs,
}
@@ -32,11 +39,24 @@ func NewFromFilesystem(fs afero.Fs) (*Manifest, error) {
func (m *Manifest) Scan() {
afero.Walk(m.SourceFS, "", func(path string, info fs.FileInfo, err error) error {
if info != nil && info.IsDir() {
// manifests contain only files, directories are implied.
return nil
}
fmt.Printf("path = %s\n", path)
fileinfo, staterr := m.SourceFS.Stat(path)
if staterr != nil {
panic(staterr)
}
nf := &ManifestFile{
Path: path,
FileInfo: info,
FileInfo: fileinfo,
}
m.Files = append(m.Files, nf)
m.TotalFileSize = m.TotalFileSize + info.Size()
return nil
})
}