From e79175264fcb9ec868af94b00f0cdbfa65e83a01 Mon Sep 17 00:00:00 2001 From: getlarge Date: Sat, 3 Aug 2024 09:16:08 +0200 Subject: [PATCH] fix(nestjs-tools-fastify-upload): fix file stream destruction logic --- packages/fastify-upload/src/lib/storage/stream-storage.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/fastify-upload/src/lib/storage/stream-storage.ts b/packages/fastify-upload/src/lib/storage/stream-storage.ts index 57fb5f1..feab686 100644 --- a/packages/fastify-upload/src/lib/storage/stream-storage.ts +++ b/packages/fastify-upload/src/lib/storage/stream-storage.ts @@ -26,7 +26,10 @@ export class StreamStorage extends Storage { if (!force) { await finished(file.stream); file.stream.destroy(); + return; + } + if (!file.stream.destroyed) { + file.stream.destroy(); } - // ? should we still check whether the stream was being read in filter phase? } }