diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index 4abfcd4a4..338caa02a 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -121,6 +121,10 @@ func DeleteFilesystem() error { logrus.Info("Deleting filesystem...") return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error { if CheckWhitelist(path) { + if !isExist(path) { + logrus.Debugf("Path %s whitelisted, but not exists", path) + return nil + } if info.IsDir() { return filepath.SkipDir } @@ -138,6 +142,14 @@ func DeleteFilesystem() error { }) } +// isExists returns true if path exists +func isExist(path string) bool { + if _, err := os.Stat(path); err == nil { + return true + } + return false +} + // ChildDirInWhitelist returns true if there is a child file or directory of the path in the whitelist func childDirInWhitelist(path string) bool { for _, d := range whitelist {