daemon/graphdriver/btrfs: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited file or directory. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1870d5f4aa
commit
8f1bc0bccc
1 changed files with 2 additions and 2 deletions
|
@ -269,7 +269,7 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error {
|
|||
var args C.struct_btrfs_ioctl_vol_args
|
||||
|
||||
// walk the btrfs subvolumes
|
||||
walkSubvolumes := func(p string, f os.FileInfo, err error) error {
|
||||
walkSubVolumes := func(p string, f os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) && p != fullPath {
|
||||
// missing most likely because the path was a subvolume that got removed in the previous iteration
|
||||
|
@ -293,7 +293,7 @@ func subvolDelete(dirpath, name string, quotaEnabled bool) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
if err := filepath.Walk(path.Join(dirpath, name), walkSubvolumes); err != nil {
|
||||
if err := filepath.WalkDir(path.Join(dirpath, name), walkSubVolumes); err != nil {
|
||||
return fmt.Errorf("Recursively walking subvolumes for %s failed: %v", dirpath, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue