fix: cleanup not available on development env

This commit is contained in:
Mar0xy 2023-11-12 17:32:24 +01:00
parent b7fc13efb7
commit bc25b28a4e
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
2 changed files with 3 additions and 3 deletions

View file

@ -9,7 +9,7 @@ export function createTemp(): Promise<[string, () => void]> {
return new Promise<[string, () => void]>((res, rej) => { return new Promise<[string, () => void]>((res, rej) => {
tmp.file((e, path, fd, cleanup) => { tmp.file((e, path, fd, cleanup) => {
if (e) return rej(e); 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) => { (e, path, cleanup) => {
if (e) return rej(e); 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 : () => {}]);
}, },
); );
}); });

View file

@ -98,7 +98,7 @@ export class ImportNotesProcessorService {
return; return;
} }
const type = job.data.type ?? ''; const type = job.data.type;
if (type === 'Twitter' || file.name.startsWith('twitter') && file.name.endsWith('.zip')) { if (type === 'Twitter' || file.name.startsWith('twitter') && file.name.endsWith('.zip')) {
const [path, cleanup] = await createTempDir(); const [path, cleanup] = await createTempDir();