зеркало из https://github.com/microsoft/docker.git
Ignore dir sizes in TreeSize func
This commit is contained in:
Родитель
a06edd77e5
Коммит
a4f14528c2
|
@ -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
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче