mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
클라이언트가 시작될 때 삭제된 파일이나 디렉터리 정보를 IndexedDB에서 삭제하도록 개선
This commit is contained in:
@@ -4,9 +4,11 @@ import {
|
||||
getDirectoryInfos as getDirectoryInfosFromIndexedDB,
|
||||
getDirectoryInfo as getDirectoryInfoFromIndexedDB,
|
||||
storeDirectoryInfo,
|
||||
deleteDirectoryInfo,
|
||||
getFileInfos as getFileInfosFromIndexedDB,
|
||||
getFileInfo as getFileInfoFromIndexedDB,
|
||||
storeFileInfo,
|
||||
deleteFileInfo,
|
||||
type DirectoryId,
|
||||
} from "$lib/indexedDB";
|
||||
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
||||
@@ -72,7 +74,13 @@ const fetchDirectoryInfoFromServer = async (
|
||||
masterKey: CryptoKey,
|
||||
) => {
|
||||
const res = await callGetApi(`/api/directory/${id}`);
|
||||
if (!res.ok) throw new Error("Failed to fetch directory information"); // TODO: Handle 404
|
||||
if (res.status === 404) {
|
||||
info.set(null);
|
||||
await deleteDirectoryInfo(id as number);
|
||||
} else if (!res.ok) {
|
||||
throw new Error("Failed to fetch directory information");
|
||||
}
|
||||
|
||||
const {
|
||||
metadata,
|
||||
subDirectories: subDirectoryIds,
|
||||
@@ -138,10 +146,16 @@ const fetchFileInfoFromServer = async (
|
||||
masterKey: CryptoKey,
|
||||
) => {
|
||||
const res = await callGetApi(`/api/file/${id}`);
|
||||
if (!res.ok) throw new Error("Failed to fetch file information"); // TODO: Handle 404
|
||||
const metadata: FileInfoResponse = await res.json();
|
||||
if (res.status === 404) {
|
||||
info.set(null);
|
||||
await deleteFileInfo(id);
|
||||
} else if (!res.ok) {
|
||||
throw new Error("Failed to fetch file information");
|
||||
}
|
||||
|
||||
const metadata: FileInfoResponse = await res.json();
|
||||
const { dataKey } = await unwrapDataKey(metadata.dek, masterKey);
|
||||
|
||||
const name = await decryptString(metadata.name, metadata.nameIv, dataKey);
|
||||
const createdAt =
|
||||
metadata.createdAt && metadata.createdAtIv
|
||||
|
||||
Reference in New Issue
Block a user