mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 08:10:28 +09:00
서버 코드를 Router, Service, Repository 계층으로 분리하고 오류 처리 및 파일 삭제 로직 개선
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed732be999
commit
6a6aa1765b
72 files changed
+1928
-1509
No files matched your search
@@ -82,3 +82,33 @@ export const newEntryParams = (userId: number, parentId: number | "root") => ({
|
||||
dekVersion: new Date(),
|
||||
encName: ciphertext(),
|
||||
});
|
||||
|
||||
export const createFile = async (userId: number, parentId: DirectoryId, path: string) => {
|
||||
const n = nextSequence();
|
||||
const { id } = await db
|
||||
.insertInto("file")
|
||||
.values({
|
||||
parent_id: parentId === "root" ? null : parentId,
|
||||
user_id: userId,
|
||||
path,
|
||||
master_encryption_key_version: 1,
|
||||
encrypted_data_encryption_key: `dek${n}`,
|
||||
data_encryption_key_version: new Date(),
|
||||
hmac_secret_key_version: null,
|
||||
content_hmac: null,
|
||||
content_type: "image/png",
|
||||
encrypted_content_iv: null,
|
||||
encrypted_content_hash: "hash",
|
||||
encrypted_name: ciphertext(),
|
||||
encrypted_created_at: null,
|
||||
encrypted_last_modified_at: ciphertext(),
|
||||
})
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow();
|
||||
return id;
|
||||
};
|
||||
|
||||
export const getQueuedDeletions = async () => {
|
||||
const rows = await db.selectFrom("file_deletion_queue").select("path").execute();
|
||||
return rows.map(({ path }) => path).sort();
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { mkdir, writeFile } from "fs/promises";
|
||||
import { dirname, join } from "path";
|
||||
import env from "#lib/server/config.js";
|
||||
|
||||
let sequence = 0;
|
||||
|
||||
export const createStoredFile = async (content: string | Buffer = "content") => {
|
||||
const path = join(env.libraryPath, "test", `file${++sequence}`);
|
||||
await mkdir(dirname(path), { recursive: true });
|
||||
await writeFile(path, content);
|
||||
return path;
|
||||
};
|
||||
Reference in new issue
Block a user