From 4f04533a3f5c7e52f5f0d6b5f2bfd4fcb556dd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agn=C3=A8s=20Toulet?= <35176601+AgnesToulet@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:10:48 +0200 Subject: [PATCH] HTTP Server: Fix CSV deletion (#530) --- src/service/http-server.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/service/http-server.ts b/src/service/http-server.ts index beeb99c5..5fa2939d 100644 --- a/src/service/http-server.ts +++ b/src/service/http-server.ts @@ -296,12 +296,17 @@ export class HttpServer { } else { try { this.log.debug('Deleting temporary file', 'file', result.filePath); - fs.unlinkSync(result.filePath); - if (!options.filePath) { - fs.rmdirSync(path.dirname(result.filePath)); - } + fs.unlink(result.filePath, (err) => { + if (err) { + throw err + } + + if (!options.filePath) { + fs.rmdir(path.dirname(result.filePath), () => {}); + } + }) } catch (e) { - this.log.error('Failed to delete temporary file', 'file', result.filePath); + this.log.error('Failed to delete temporary file', 'file', result.filePath, 'error', e.message); } } });