mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-03 23:56:53 +00:00
삭제된 파일, 카테고리, 디렉터리에 대한 정보가 IndexedDB에서 삭제되지 않는 버그 수정
This commit is contained in:
@@ -62,6 +62,16 @@ export const deleteDirectoryInfo = async (id: number) => {
|
||||
await filesystem.directory.delete(id);
|
||||
};
|
||||
|
||||
export const deleteDanglingDirectoryInfos = async (
|
||||
parentId: DirectoryId,
|
||||
validIds: Set<number>,
|
||||
) => {
|
||||
await filesystem.directory
|
||||
.where({ parentId })
|
||||
.and((directory) => !validIds.has(directory.id))
|
||||
.delete();
|
||||
};
|
||||
|
||||
export const getAllFileInfos = async () => {
|
||||
return await filesystem.file.toArray();
|
||||
};
|
||||
@@ -86,6 +96,13 @@ export const deleteFileInfo = async (id: number) => {
|
||||
await filesystem.file.delete(id);
|
||||
};
|
||||
|
||||
export const deleteDanglingFileInfos = async (parentId: DirectoryId, validIds: Set<number>) => {
|
||||
await filesystem.file
|
||||
.where({ parentId })
|
||||
.and((file) => !validIds.has(file.id))
|
||||
.delete();
|
||||
};
|
||||
|
||||
export const getCategoryInfos = async (parentId: CategoryId) => {
|
||||
return await filesystem.category.where({ parentId }).toArray();
|
||||
};
|
||||
@@ -106,6 +123,13 @@ export const deleteCategoryInfo = async (id: number) => {
|
||||
await filesystem.category.delete(id);
|
||||
};
|
||||
|
||||
export const deleteDanglingCategoryInfos = async (parentId: CategoryId, validIds: Set<number>) => {
|
||||
await filesystem.category
|
||||
.where({ parentId })
|
||||
.and((category) => !validIds.has(category.id))
|
||||
.delete();
|
||||
};
|
||||
|
||||
export const cleanupDanglingInfos = async () => {
|
||||
const validDirectoryIds: number[] = [];
|
||||
const validFileIds: number[] = [];
|
||||
|
||||
@@ -53,6 +53,9 @@ const fetchFromServer = async (id: CategoryId, masterKey: CryptoKey) => {
|
||||
subCategories: subCategoriesRaw,
|
||||
files: filesRaw,
|
||||
} = await trpc().category.get.query({ id, recurse: true });
|
||||
|
||||
void IndexedDB.deleteDanglingCategoryInfos(id, new Set(subCategoriesRaw.map(({ id }) => id)));
|
||||
|
||||
const subCategories = await Promise.all(
|
||||
subCategoriesRaw.map(async (category) => {
|
||||
const decrypted = await decryptCategoryMetadata(category, masterKey);
|
||||
|
||||
@@ -39,6 +39,10 @@ const fetchFromServer = async (id: DirectoryId, masterKey: CryptoKey) => {
|
||||
subDirectories: subDirectoriesRaw,
|
||||
files: filesRaw,
|
||||
} = await trpc().directory.get.query({ id });
|
||||
|
||||
void IndexedDB.deleteDanglingDirectoryInfos(id, new Set(subDirectoriesRaw.map(({ id }) => id)));
|
||||
void IndexedDB.deleteDanglingFileInfos(id, new Set(filesRaw.map(({ id }) => id)));
|
||||
|
||||
const existingFiles = await IndexedDB.bulkGetFileInfos(filesRaw.map((file) => file.id));
|
||||
const [subDirectories, files, decryptedMetadata] = await Promise.all([
|
||||
Promise.all(
|
||||
|
||||
Reference in New Issue
Block a user