mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
파일 업로드에 성공한 경우 캐시에도 파일을 저장하도록 개선
This commit is contained in:
@@ -50,7 +50,7 @@ export const createClient = async (encPubKey: string, sigPubKey: string, userId:
|
||||
.insertInto("user_client")
|
||||
.values({ user_id: userId, client_id: clientId })
|
||||
.execute();
|
||||
return { clientId };
|
||||
return { id: clientId };
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ export const registerFile = async (params: NewFile) => {
|
||||
throw new Error("Invalid arguments");
|
||||
}
|
||||
|
||||
await db.transaction().execute(async (trx) => {
|
||||
return await db.transaction().execute(async (trx) => {
|
||||
const mek = await trx
|
||||
.selectFrom("master_encryption_key")
|
||||
.select("version")
|
||||
@@ -259,6 +259,7 @@ export const registerFile = async (params: NewFile) => {
|
||||
new_name: params.encName,
|
||||
})
|
||||
.execute();
|
||||
return { id: fileId };
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -60,3 +60,8 @@ export const fileUploadRequest = z.object({
|
||||
lastModifiedAtIv: z.string().base64().nonempty(),
|
||||
});
|
||||
export type FileUploadRequest = z.infer<typeof fileUploadRequest>;
|
||||
|
||||
export const fileUploadResponse = z.object({
|
||||
file: z.number().int().positive(),
|
||||
});
|
||||
export type FileUploadResponse = z.infer<typeof fileUploadResponse>;
|
||||
|
||||
@@ -63,7 +63,7 @@ export const registerUserClient = async (
|
||||
}
|
||||
|
||||
try {
|
||||
const { clientId } = await createClient(encPubKey, sigPubKey, userId);
|
||||
const { id: clientId } = await createClient(encPubKey, sigPubKey, userId);
|
||||
return { challenge: await createUserClientChallenge(ip, userId, clientId, encPubKey) };
|
||||
} catch (e) {
|
||||
if (e instanceof IntegrityError && e.message === "Public key(s) already registered") {
|
||||
|
||||
@@ -131,11 +131,12 @@ export const uploadFile = async (
|
||||
throw new Error("Invalid checksum");
|
||||
}
|
||||
|
||||
await registerFile({
|
||||
const { id: fileId } = await registerFile({
|
||||
...params,
|
||||
path,
|
||||
encContentHash: hash,
|
||||
});
|
||||
return { fileId };
|
||||
} catch (e) {
|
||||
await safeUnlink(path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user