LocalStorageAdapter delete catch block solved

This commit is contained in:
Yasindu20 2026-01-22 16:08:45 +05:30
parent 631314dea8
commit 0c72d5a37c

View file

@ -3,7 +3,7 @@ import { promises as fs } from "fs";
import path from "path"; import path from "path";
export class LocalStorageAdapter implements IStorageAdapter { export class LocalStorageAdapter implements IStorageAdapter {
baseDir: string; private baseDir: string;
constructor(baseDir: string) { constructor(baseDir: string) {
this.baseDir = baseDir; this.baseDir = baseDir;
@ -25,8 +25,14 @@ export class LocalStorageAdapter implements IStorageAdapter {
const fullPath = path.join(this.baseDir, key); const fullPath = path.join(this.baseDir, key);
try { try {
await fs.unlink(fullPath); await fs.unlink(fullPath);
} catch { } catch (error) {
//ignore error if file does not exist 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
} }
} }