Skip to content

Commit 970e1f4

Browse files
committed
fix: cannot upload or delete logo (closes #230)
1 parent da4562d commit 970e1f4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

server/src/storage/delete-file.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import { getFilePath } from './get-file-path';
22
import { promises } from 'fs';
33

4-
export function deleteFile(id: string): Promise<void> {
4+
async function fileExists(path: string): Promise<boolean> {
5+
try {
6+
await promises.stat(path);
7+
return true;
8+
} catch (e) {
9+
return false;
10+
}
11+
}
12+
13+
export async function deleteFile(id: string): Promise<void> {
514
const filePath = getFilePath(id);
15+
16+
const exists = await fileExists(filePath);
17+
if (!exists) {
18+
return;
19+
}
20+
621
return promises.unlink(filePath);
722
}

0 commit comments

Comments
 (0)