summaryrefslogtreecommitdiff
path: root/libpod/volume.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-03-26 06:39:11 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2022-03-27 07:18:25 -0400
commitd106b294b428fbb10f59d4cafe72c3dcaa4e73bb (patch)
tree3c81aa0b8452565c704629258643eb6c51b82b3e /libpod/volume.go
parent56b2937f87bd67b46aa93109aefc08ce0edb5cf1 (diff)
downloadpodman-d106b294b428fbb10f59d4cafe72c3dcaa4e73bb.tar.gz
podman-d106b294b428fbb10f59d4cafe72c3dcaa4e73bb.tar.bz2
podman-d106b294b428fbb10f59d4cafe72c3dcaa4e73bb.zip
Switch all calls to filepath.Walk to filepath.WalkDir
WalkDir should be faster the Walk, since we often do not need to stat files. [NO NEW TESTS NEEDED] Existing tests should find errors. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/volume.go')
-rw-r--r--libpod/volume.go12
1 files changed, 2 insertions, 10 deletions
diff --git a/libpod/volume.go b/libpod/volume.go
index f79ceaa87..bffafdc15 100644
--- a/libpod/volume.go
+++ b/libpod/volume.go
@@ -1,13 +1,12 @@
package libpod
import (
- "os"
- "path/filepath"
"time"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/libpod/lock"
"github.com/containers/podman/v4/libpod/plugin"
+ "github.com/containers/podman/v4/pkg/util"
)
// Volume is a libpod named volume.
@@ -93,14 +92,7 @@ func (v *Volume) Name() string {
// Returns the size on disk of volume
func (v *Volume) Size() (uint64, error) {
- var size uint64
- err := filepath.Walk(v.config.MountPoint, func(path string, info os.FileInfo, err error) error {
- if err == nil && !info.IsDir() {
- size += (uint64)(info.Size())
- }
- return err
- })
- return size, err
+ return util.SizeOfPath(v.config.MountPoint)
}
// Driver retrieves the volume's driver.