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

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

@@ -19,6 +19,7 @@ import type {
HmacSecretListResponse,
DuplicateFileScanRequest,
DuplicateFileScanResponse,
DirectoryDeleteResponse,
} from "$lib/server/schemas";
import { hmacSecretStore, type MasterKey, type HmacSecret } from "$lib/stores";
@@ -191,6 +192,15 @@ export const requestDirectoryEntryRename = async (
};
export const requestDirectoryEntryDeletion = async (entry: SelectedDirectoryEntry) => {
await callPostApi(`/api/${entry.type}/${entry.id}/delete`);
await deleteFileCache(entry.id);
const res = await callPostApi(`/api/${entry.type}/${entry.id}/delete`);
if (!res.ok) return false;
if (entry.type === "directory") {
const { deletedFiles }: DirectoryDeleteResponse = await res.json();
await Promise.all(deletedFiles.map(deleteFileCache));
return true;
} else {
await deleteFileCache(entry.id);
return true;
}
};