Skip to content

Commit

Permalink
fix: EMFILE: too many open files error while sigining
Browse files Browse the repository at this point in the history
copied from electron#286
  • Loading branch information
mwakizaka committed Aug 5, 2023
1 parent c6aa0f3 commit 0b8f446
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,33 +136,32 @@ export async function walkAsync (dirPath: string): Promise<string[]> {
debugLog('Walking... ' + dirPath);

async function _walkAsync (dirPath: string): Promise<DeepList<string>> {
const res: DeepList<string> = [];
const children = await fs.readdir(dirPath);
return await Promise.all(
children.map(async (child) => {
const filePath = path.resolve(dirPath, child);

const stat = await fs.stat(filePath);
if (stat.isFile()) {
switch (path.extname(filePath)) {
case '.cstemp': // Temporary file generated from past codesign
debugLog('Removing... ' + filePath);
await fs.remove(filePath);
return null;
default:
return await getFilePathIfBinary(filePath);
}
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
const walkResult = await _walkAsync(filePath);
switch (path.extname(filePath)) {
case '.app': // Application
case '.framework': // Framework
walkResult.push(filePath);
}
return walkResult;
for (const child of children) {
const filePath = path.resolve(dirPath, child);
const stat = await fs.stat(filePath);
if (stat.isFile()) {
switch (path.extname(filePath)) {
case '.cstemp': // Temporary file generated from past codesign
debugLog('Removing... ' + filePath);
await fs.remove(filePath);
break;
default:
await getFilePathIfBinary(filePath) && res.push(filePath);
break;
}
return null;
})
);
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
const walkResult = await _walkAsync(filePath);
switch (path.extname(filePath)) {
case '.app': // Application
case '.framework': // Framework
walkResult.push(filePath);
}
res.push(walkResult);
}
}
return res;
}

const allPaths = await _walkAsync(dirPath);
Expand Down

0 comments on commit 0b8f446

Please sign in to comment.