提交 ab7ae128 编写于 作者: E Erich Gamma

Immediatly stop counting when MAXFILES is reached

上级 f806fc6d
......@@ -79,12 +79,12 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Workspa
const MAX_FILES = 20000;
let walkSync = (dir: string, acceptFile: (fileName: string) => void, filter: string[], token) => {
if (token.maxReached) {
return;
}
try {
let files = readdirSync(dir);
for (const file of files) {
if (token.maxReached) {
return;
}
try {
if (statSync(join(dir, file)).isDirectory()) {
if (filter.indexOf(file) === -1) {
......@@ -92,10 +92,11 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Workspa
}
}
else {
if (token.count++ >= MAX_FILES) {
if (token.count >= MAX_FILES) {
token.maxReached = true;
return;
}
token.count++;
acceptFile(file);
}
} catch {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册