파일 썸네일이 캐시되는 OPFS의 경로 변경

This commit is contained in:
static
2025-07-07 18:29:04 +09:00
parent d3de06a7f9
commit 40a87aa81f
10 changed files with 56 additions and 58 deletions

View File

@@ -1,6 +1,12 @@
import { callGetApi } from "$lib/hooks";
import { decryptData } from "$lib/modules/crypto";
import { getFileCache, storeFileCache, downloadFile, storeFileThumbnail } from "$lib/modules/file";
import {
getFileCache,
storeFileCache,
getFileThumbnailCache,
storeFileThumbnailCache,
downloadFile,
} from "$lib/modules/file";
import { getThumbnailUrl } from "$lib/modules/thumbnail";
import type { FileThumbnailInfoResponse } from "$lib/server/schemas";
@@ -18,6 +24,9 @@ export const requestFileDownload = async (
};
export const requestFileThumbnailDownload = async (fileId: number, dataKey: CryptoKey) => {
const cache = await getFileThumbnailCache(fileId);
if (cache) return cache;
let res = await callGetApi(`/api/file/${fileId}/thumbnail`);
if (!res.ok) return null;
@@ -29,6 +38,6 @@ export const requestFileThumbnailDownload = async (fileId: number, dataKey: Cryp
const thumbnailEncrypted = await res.arrayBuffer();
const thumbnail = await decryptData(thumbnailEncrypted, thumbnailEncryptedIv, dataKey);
storeFileThumbnail(fileId, thumbnail); // Intended
storeFileThumbnailCache(fileId, thumbnail); // Intended
return getThumbnailUrl(thumbnail);
};