mirror of
https://github.com/containers/podman.git
synced 2025-12-16 03:57:36 +08:00
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>
This commit is contained in:
@@ -2,6 +2,7 @@ package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -46,14 +47,14 @@ var _ = Describe("Podman pod rm", func() {
|
||||
Expect(result).Should(Exit(0))
|
||||
|
||||
// Also check that we don't leak cgroups
|
||||
err := filepath.Walk("/sys/fs/cgroup", func(path string, info os.FileInfo, err error) error {
|
||||
err := filepath.WalkDir("/sys/fs/cgroup", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
if !d.IsDir() {
|
||||
Expect(err).To(BeNil())
|
||||
}
|
||||
if strings.Contains(info.Name(), podid) {
|
||||
if strings.Contains(d.Name(), podid) {
|
||||
return fmt.Errorf("leaking cgroup path %s", path)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user