From 0c72d5a37c11a60d11e23fa3c9367470e31c1855 Mon Sep 17 00:00:00 2001 From: Yasindu20 Date: Thu, 22 Jan 2026 16:08:45 +0530 Subject: [PATCH] LocalStorageAdapter delete catch block solved --- src/storage/LocalStorageAdapter.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/storage/LocalStorageAdapter.ts b/src/storage/LocalStorageAdapter.ts index f849fa1..86fc733 100644 --- a/src/storage/LocalStorageAdapter.ts +++ b/src/storage/LocalStorageAdapter.ts @@ -3,7 +3,7 @@ import { promises as fs } from "fs"; import path from "path"; export class LocalStorageAdapter implements IStorageAdapter { - baseDir: string; + private baseDir: string; constructor(baseDir: string) { this.baseDir = baseDir; @@ -25,8 +25,14 @@ export class LocalStorageAdapter implements IStorageAdapter { const fullPath = path.join(this.baseDir, key); try { await fs.unlink(fullPath); - } catch { - //ignore error if file does not exist + } catch (error) { + const err = error as NodeJS.ErrnoException; + if (err?.code === "ENOENT" || err?.code === "ENOTDIR") { + return; + } + + console.error(`Failed to delete file at ${fullPath}: `, error); + throw error } }