Skip to content

Commit

Permalink
fix(pipeline): check existence of path before creation (#676)
Browse files Browse the repository at this point in the history
in the case of windows users using a drive letter only for their paths
(`X:\\`) then mkdir will fail for operation not permitted, as you cannot
create a drive letter.

this will check if the path exists before creation, if so it wont
attempt to create it preventing a stack from being thrown.

```node:fs:1373
  const result = binding.mkdir(
                         ^

Error: EPERM: operation not permitted, mkdir 'Z:\'
    at Object.mkdirSync (node:fs:1373:26)
    at main (file:///C:/Users/Audio.Main/AppData/Roaming/npm/node_modules/cross-seed/dist/pipeline.js:183:8)
    at async Command.<anonymous> (file:///C:/Users/Audio.Main/AppData/Roaming/npm/node_modules/cross-seed/dist/cmd.js:235:9)
    at async Command.parseAsync (C:\Users\Audio.Main\AppData\Roaming\npm\node_modules\cross-seed\node_modules\commander\lib\command.js:923:5)
    at async file:///C:/Users/Audio.Main/AppData/Roaming/npm/node_modules/cross-seed/dist/cmd.js:244:1 {
  errno: -4048,
  code: 'EPERM',
  syscall: 'mkdir',
  path: 'Z:\\'
}
```
  • Loading branch information
zakkarry committed May 9, 2024
1 parent 235c336 commit cbe601e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ export async function main(): Promise<void> {
const { outputDir, linkDir } = getRuntimeConfig();
const { samples, hashesToExclude } = await findSearchableTorrents();

fs.mkdirSync(outputDir, { recursive: true });
if (linkDir) {
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
if (linkDir && !fs.existsSync(linkDir)) {
fs.mkdirSync(linkDir, { recursive: true });
}

const totalFound = await findMatchesBatch(samples, hashesToExclude);

logger.info({
Expand Down

0 comments on commit cbe601e

Please sign in to comment.