mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 20:32:46 +00:00
chore(lint): parallelize Linux watch directory traversal
Switch BFS to level-by-level Promise.all over readdir calls, replacing the sequential pop/await loop that triggered no-await-in-loop.
This commit is contained in:
@@ -1164,29 +1164,33 @@ export class WorkspaceGitServiceImpl implements WorkspaceGitService {
|
|||||||
|
|
||||||
private async listLinuxWatchDirectories(rootPath: string): Promise<string[]> {
|
private async listLinuxWatchDirectories(rootPath: string): Promise<string[]> {
|
||||||
const directories: string[] = [];
|
const directories: string[] = [];
|
||||||
const pending = [rootPath];
|
let currentLevel: string[] = [rootPath];
|
||||||
|
|
||||||
while (pending.length > 0) {
|
while (currentLevel.length > 0) {
|
||||||
const directory = pending.pop();
|
directories.push(...currentLevel);
|
||||||
if (!directory) {
|
const readResults = await Promise.all(
|
||||||
continue;
|
currentLevel.map(async (directory) => {
|
||||||
}
|
|
||||||
directories.push(directory);
|
|
||||||
|
|
||||||
let entries;
|
|
||||||
try {
|
try {
|
||||||
entries = await this.deps.readdir(directory, { withFileTypes: true });
|
return await this.deps.readdir(directory, { withFileTypes: true });
|
||||||
} catch {
|
} catch {
|
||||||
continue;
|
return null;
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const nextLevel: string[] = [];
|
||||||
|
for (let i = 0; i < currentLevel.length; i += 1) {
|
||||||
|
const directory = currentLevel[i];
|
||||||
|
const entries = readResults[i];
|
||||||
|
if (!directory || !entries) continue;
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (!entry.isDirectory() || entry.name === ".git") {
|
if (!entry.isDirectory() || entry.name === ".git") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pending.push(join(directory, entry.name));
|
nextLevel.push(join(directory, entry.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
currentLevel = nextLevel;
|
||||||
|
}
|
||||||
|
|
||||||
return directories;
|
return directories;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user