runtime: fix the bug of func countFiles

When the total number of files observed is greater than limit, return (-1, err).
When the returned err is not nil, the func countFiles should return -1.

Fixes:#9780

Signed-off-by: gaohuatao <gaohuatao@bytedance.com>
This commit is contained in:
gaohuatao 2024-06-06 11:50:59 +08:00
parent b30d085271
commit 638e9acf89

View File

@ -388,7 +388,11 @@ func countFiles(path string, limit int) (numFiles int, err error) {
if file.IsDir() {
inc, err := countFiles(filepath.Join(path, file.Name()), (limit - numFiles))
if err != nil {
return numFiles, err
return 0, err
}
// exceeded limit
if inc == -1 {
return -1, nil
}
numFiles = numFiles + inc
} else {