Selaa lähdekoodia

oci: 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>
Sebastiaan van Stijn 2 vuotta sitten
vanhempi
commit
0ee5518e76
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      oci/devices_linux.go

+ 1 - 1
oci/devices_linux.go

@@ -45,7 +45,7 @@ func DevicesFromPath(pathOnHost, pathInContainer, cgroupPermissions string) (dev
 		if src, e := os.Stat(resolvedPathOnHost); e == nil && src.IsDir() {
 		if src, e := os.Stat(resolvedPathOnHost); e == nil && src.IsDir() {
 			// mount the internal devices recursively
 			// mount the internal devices recursively
 			// TODO check if additional errors should be handled or logged
 			// TODO check if additional errors should be handled or logged
-			_ = filepath.Walk(resolvedPathOnHost, func(dpath string, f os.FileInfo, _ error) error {
+			_ = filepath.WalkDir(resolvedPathOnHost, func(dpath string, f os.DirEntry, _ error) error {
 				childDevice, e := coci.DeviceFromPath(dpath)
 				childDevice, e := coci.DeviceFromPath(dpath)
 				if e != nil {
 				if e != nil {
 					// ignore the device
 					// ignore the device