Skip to content

Commit

Permalink
fix: cannot upload or delete logo (closes #230)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed May 21, 2021
1 parent da4562d commit 970e1f4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion server/src/storage/delete-file.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { getFilePath } from './get-file-path';
import { promises } from 'fs';

export function deleteFile(id: string): Promise<void> {
async function fileExists(path: string): Promise<boolean> {
try {
await promises.stat(path);
return true;
} catch (e) {
return false;
}
}

export async function deleteFile(id: string): Promise<void> {
const filePath = getFilePath(id);

const exists = await fileExists(filePath);
if (!exists) {
return;
}

return promises.unlink(filePath);
}

0 comments on commit 970e1f4

Please sign in to comment.