mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
파일 캐시 추가
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { getFileCache, storeFileCache } from "$lib/modules/cache";
|
||||
import { decryptData } from "$lib/modules/crypto";
|
||||
|
||||
export const requestFileDownload = (
|
||||
export const requestFileDownload = async (
|
||||
fileId: number,
|
||||
fileEncryptedIv: string,
|
||||
dataKey: CryptoKey,
|
||||
) => {
|
||||
const cache = await getFileCache(fileId);
|
||||
if (cache) return cache;
|
||||
|
||||
return new Promise<ArrayBuffer>((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.responseType = "arraybuffer";
|
||||
@@ -21,6 +25,7 @@ export const requestFileDownload = (
|
||||
dataKey,
|
||||
);
|
||||
resolve(fileDecrypted);
|
||||
await storeFileCache(fileId, fileDecrypted);
|
||||
});
|
||||
|
||||
// TODO: Progress, ...
|
||||
|
||||
Reference in New Issue
Block a user