mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Ignore dir sizes in TreeSize func
This commit is contained in:
parent
a06edd77e5
commit
a4f14528c2
2 changed files with 5 additions and 3 deletions
|
@ -426,7 +426,6 @@ func TestChanges(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: How to properly test this?
|
||||
func TestDiffSize(t *testing.T) {
|
||||
d := newDriver(t)
|
||||
defer os.RemoveAll(tmp)
|
||||
|
@ -457,7 +456,7 @@ func TestDiffSize(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
diffSize, err := d.DiffSize("1")
|
||||
diffSize, err := d.Size("1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -465,4 +464,3 @@ func TestDiffSize(t *testing.T) {
|
|||
t.Fatalf("Expected size to be %d got %d", size, diffSize)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,10 @@ import (
|
|||
// TreeSize walks a directory tree and returns its total size in bytes.
|
||||
func TreeSize(dir string) (size int64, err error) {
|
||||
err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error {
|
||||
// Ignore directory sizes
|
||||
if fileInfo.IsDir() {
|
||||
return nil
|
||||
}
|
||||
size += fileInfo.Size()
|
||||
return nil
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue