프론트엔드에서의 파일 업로드 전 중복 검사 구현

This commit is contained in:
static
2025-01-13 00:46:35 +09:00
parent 59c8523e25
commit 5c7dc58f03
8 changed files with 161 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import { v4 as uuidv4 } from "uuid";
import { IntegrityError } from "$lib/server/db/error";
import {
registerFile,
getAllFileIdsByContentHmac,
getFile,
setFileEncName,
unregisterFile,
@@ -76,6 +77,15 @@ export const renameFile = async (
}
};
export const scanDuplicateFiles = async (
userId: number,
hskVersion: number,
contentHmac: string,
) => {
const fileIds = await getAllFileIdsByContentHmac(userId, hskVersion, contentHmac);
return { files: fileIds.map(({ id }) => id) };
};
const safeUnlink = async (path: string) => {
await unlink(path).catch(console.error);
};