Report the right size to Top

This commit is contained in:
Blallo 2020-03-03 14:16:54 +01:00
parent 67e51c9f1b
commit 3db212b3c6
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F
2 changed files with 8 additions and 5 deletions

View file

@ -221,7 +221,7 @@ func (i *Intermediate) Spawn(maxLevel int) error {
func (i *Intermediate) Collect() error { func (i *Intermediate) Collect() error {
for s := range i.collect { for s := range i.collect {
i.size += s i.size += s
i.refer <- i.size i.refer <- s
} }
close(i.refer) close(i.refer)
return nil return nil
@ -330,7 +330,7 @@ func (b *Bottom) Spawn(maxLevel int) error {
func (b *Bottom) Collect() error { func (b *Bottom) Collect() error {
for s := range b.collect { for s := range b.collect {
b.size += s b.size += s
b.refer <- b.size b.refer <- s
} }
close(b.refer) close(b.refer)
return nil return nil

View file

@ -11,10 +11,13 @@ type RealWalker struct {
} }
func (r *RealWalker) walkFunc(path string, info os.FileInfo, err error) error { func (r *RealWalker) walkFunc(path string, info os.FileInfo, err error) error {
switch mode := info.Mode(); { if !info.IsDir() {
case mode.IsRegular(): switch mode := info.Mode(); {
r.report <- info.Size() case mode.IsRegular():
r.report <- info.Size()
}
} }
return nil return nil
} }