디렉터리를 삭제하는 경우, 디렉터리 하위에 있던 파일의 캐시를 자동으로 삭제하도록 구현

This commit is contained in:
static
2025-01-14 03:37:31 +09:00
parent 27d2b83464
commit 4bd666a5d5
6 changed files with 51 additions and 16 deletions

View File

@@ -34,8 +34,13 @@ export const getDirectoryInformation = async (userId: number, directoryId: "root
export const deleteDirectory = async (userId: number, directoryId: number) => {
try {
const filePaths = await unregisterDirectory(userId, directoryId);
filePaths.map((path) => unlink(path)); // Intended
const files = await unregisterDirectory(userId, directoryId);
return {
files: files.map(({ id, path }) => {
unlink(path); // Intended
return id;
}),
};
} catch (e) {
if (e instanceof IntegrityError && e.message === "Directory not found") {
error(404, "Invalid directory id");