Skip to content

Commit

Permalink
Only check pending directory on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Nov 18, 2022
1 parent c1e28e9 commit 59d5ebb
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/main/integrations/sentry-minidump/minidump-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,17 @@ async function deleteCrashpadMetadataFile(crashesDirectory: string, waitMs: numb
}
}

async function readDirAsyncIfExists(path: string): Promise<string[]> {
try {
return await readDirAsync(path);
} catch (_) {
return [];
async function readDirsAsync(paths: string[]): Promise<string[]> {
const found: string[] = [];
for (const path of paths) {
try {
const files = await readDirAsync(path);
found.push(...files.map((file) => join(path, file)));
} catch (_) {
//
}
}
return found;
}

function crashpadMinidumpLoader(): MinidumpLoader {
Expand All @@ -101,31 +106,20 @@ function crashpadMinidumpLoader(): MinidumpLoader {
return createMinidumpLoader(async () => {
await deleteCrashpadMetadataFile(crashesDirectory).catch((error) => logger.error(error));

const dumpDirectory = join(crashesDirectory, crashpadSubDirectory);
const pendingDirectory = join(crashesDirectory, 'pending');
const dumpDirectories = [join(crashesDirectory, crashpadSubDirectory)];

return (await readDirAsyncIfExists(dumpDirectory))
.filter((file) => file.endsWith('.dmp'))
.map((file) => {
const path = join(dumpDirectory, file);
if (process.platform === 'darwin') {
dumpDirectories.push(join(crashesDirectory, 'pending'));
}

return (await readDirsAsync(dumpDirectories))
.filter((file) => file.endsWith('.dmp'))
.map((path) => {
return {
path,
load: () => readFileAsync(path),
};
})
.concat(
(await readDirAsyncIfExists(pendingDirectory))
.filter((file) => file.endsWith('.dmp'))
.map((file) => {
const path = join(pendingDirectory, file);

return {
path,
load: () => readFileAsync(path),
};
}),
);
});
});
}

Expand Down

0 comments on commit 59d5ebb

Please sign in to comment.