파일 및 디렉터리 목록을 IndexedDB에 캐싱하도록 구현

This commit is contained in:
static
2025-01-17 12:22:51 +09:00
parent 7e711c1b8f
commit 7aa6ba0eab
23 changed files with 285 additions and 165 deletions

View File

@@ -3,8 +3,8 @@
import { untrack } from "svelte";
import type { Writable } from "svelte/store";
import { TopBar } from "$lib/components";
import { getFileInfo } from "$lib/modules/file";
import { masterKeyStore, type FileInfo } from "$lib/stores";
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem";
import { masterKeyStore } from "$lib/stores";
import { requestFileDownload } from "./service";
type ContentType = "image" | "video";
@@ -27,7 +27,7 @@
});
$effect(() => {
if ($info && !isDownloaded) {
if ($info?.contentIv && $info?.dataKey && !isDownloaded) {
untrack(() => {
isDownloaded = true;
@@ -37,7 +37,7 @@
contentType = "video";
}
requestFileDownload(data.id, $info.contentIv, $info.dataKey).then(async (res) => {
requestFileDownload(data.id, $info.contentIv!, $info.dataKey!).then(async (res) => {
content = new Blob([res], { type: $info.contentType });
if (content.type === "image/heic" || content.type === "image/heif") {
const { default: heic2any } = await import("heic2any");

View File

@@ -3,8 +3,9 @@
import type { Writable } from "svelte/store";
import { TopBar } from "$lib/components";
import type { FileCacheIndex } from "$lib/indexedDB";
import { getFileCacheIndex, getFileInfo } from "$lib/modules/file";
import { masterKeyStore, type FileInfo } from "$lib/stores";
import { getFileCacheIndex } from "$lib/modules/file";
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem";
import { masterKeyStore } from "$lib/stores";
import File from "./File.svelte";
import { formatFileSize, deleteFileCache as doDeleteFileCache } from "./service";

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import type { Writable } from "svelte/store";
import type { FileCacheIndex } from "$lib/indexedDB";
import type { FileInfo } from "$lib/stores";
import type { FileInfo } from "$lib/modules/filesystem";
import { formatDate, formatFileSize } from "./service";
import IconDraft from "~icons/material-symbols/draft";