Skip to content

Commit 0c72d5a

Browse files
committed
LocalStorageAdapter delete catch block solved
1 parent 631314d commit 0c72d5a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/storage/LocalStorageAdapter.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { promises as fs } from "fs";
33
import path from "path";
44

55
export class LocalStorageAdapter implements IStorageAdapter {
6-
baseDir: string;
6+
private baseDir: string;
77

88
constructor(baseDir: string) {
99
this.baseDir = baseDir;
@@ -25,8 +25,14 @@ export class LocalStorageAdapter implements IStorageAdapter {
2525
const fullPath = path.join(this.baseDir, key);
2626
try {
2727
await fs.unlink(fullPath);
28-
} catch {
29-
//ignore error if file does not exist
28+
} catch (error) {
29+
const err = error as NodeJS.ErrnoException;
30+
if (err?.code === "ENOENT" || err?.code === "ENOTDIR") {
31+
return;
32+
}
33+
34+
console.error(`Failed to delete file at ${fullPath}: `, error);
35+
throw error
3036
}
3137
}
3238

0 commit comments

Comments
 (0)