From bc25b28a4ee46a4264ffe3f7e05ff6b58993fd15 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 12 Nov 2023 17:32:24 +0100 Subject: [PATCH] fix: cleanup not available on development env --- packages/backend/src/misc/create-temp.ts | 4 ++-- .../src/queue/processors/ImportNotesProcessorService.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/misc/create-temp.ts b/packages/backend/src/misc/create-temp.ts index 2bb0e8848..5b4943b7a 100644 --- a/packages/backend/src/misc/create-temp.ts +++ b/packages/backend/src/misc/create-temp.ts @@ -9,7 +9,7 @@ export function createTemp(): Promise<[string, () => void]> { return new Promise<[string, () => void]>((res, rej) => { tmp.file((e, path, fd, cleanup) => { if (e) return rej(e); - res([path, process.env.NODE_ENV === 'production' ? cleanup : () => {}]); + res([path, process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'development' ? cleanup : () => {}]); }); }); } @@ -22,7 +22,7 @@ export function createTempDir(): Promise<[string, () => void]> { }, (e, path, cleanup) => { if (e) return rej(e); - res([path, process.env.NODE_ENV === 'production' ? cleanup : () => {}]); + res([path, process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'development' ? cleanup : () => {}]); }, ); }); diff --git a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts index 9a9858304..b209d7239 100644 --- a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts @@ -98,7 +98,7 @@ export class ImportNotesProcessorService { return; } - const type = job.data.type ?? ''; + const type = job.data.type; if (type === 'Twitter' || file.name.startsWith('twitter') && file.name.endsWith('.zip')) { const [path, cleanup] = await createTempDir();