mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-12 21:08:46 +00:00
thumbnail 테이블의 created_at 컬럼의 이름을 updated_at으로 변경
This commit is contained in:
@@ -5,7 +5,7 @@ import db from "./kysely";
|
||||
interface Thumbnail {
|
||||
id: number;
|
||||
path: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
encContentIv: string;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ export const updateFileThumbnail = async (
|
||||
.values({
|
||||
file_id: fileId,
|
||||
path,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
encrypted_content_iv: encContentIv,
|
||||
})
|
||||
.onConflict((oc) =>
|
||||
oc.column("file_id").doUpdateSet({
|
||||
path,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
encrypted_content_iv: encContentIv,
|
||||
}),
|
||||
)
|
||||
@@ -80,7 +80,7 @@ export const getFileThumbnail = async (userId: number, fileId: number) => {
|
||||
fileId: thumbnail.file_id,
|
||||
path: thumbnail.path,
|
||||
encContentIv: thumbnail.encrypted_content_iv,
|
||||
createdAt: thumbnail.created_at,
|
||||
updatedAt: thumbnail.updated_at,
|
||||
} satisfies FileThumbnail)
|
||||
: null;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ export const up = async (db: Kysely<any>) => {
|
||||
col.references("category.id").onDelete("cascade").unique(),
|
||||
)
|
||||
.addColumn("path", "text", (col) => col.unique().notNull())
|
||||
.addColumn("created_at", "timestamp(3)", (col) => col.notNull())
|
||||
.addColumn("updated_at", "timestamp(3)", (col) => col.notNull())
|
||||
.addColumn("encrypted_content_iv", "text", (col) => col.notNull())
|
||||
.addCheckConstraint(
|
||||
"thumbnail_ck01",
|
||||
|
||||
@@ -6,7 +6,7 @@ interface ThumbnailTable {
|
||||
file_id: number | null;
|
||||
category_id: number | null;
|
||||
path: string;
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
encrypted_content_iv: string; // Base64
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ export const fileRenameRequest = z.object({
|
||||
export type FileRenameRequest = z.infer<typeof fileRenameRequest>;
|
||||
|
||||
export const fileThumbnailInfoResponse = z.object({
|
||||
updatedAt: z.string().datetime(),
|
||||
encContentIv: z.string().base64().nonempty(),
|
||||
});
|
||||
export type FileThumbnailInfoResponse = z.infer<typeof fileThumbnailInfoResponse>;
|
||||
|
||||
@@ -92,7 +92,7 @@ export const getFileThumbnailInformation = async (userId: number, fileId: number
|
||||
error(404, "File or its thumbnail not found");
|
||||
}
|
||||
|
||||
return { encContentIv: thumbnail.encContentIv };
|
||||
return { updatedAt: thumbnail.updatedAt, encContentIv: thumbnail.encContentIv };
|
||||
};
|
||||
|
||||
export const getFileThumbnailStream = async (userId: number, fileId: number) => {
|
||||
|
||||
@@ -16,8 +16,11 @@ export const GET: RequestHandler = async ({ locals, params }) => {
|
||||
if (!zodRes.success) error(400, "Invalid path parameters");
|
||||
const { id } = zodRes.data;
|
||||
|
||||
const { encContentIv } = await getFileThumbnailInformation(userId, id);
|
||||
const { updatedAt, encContentIv } = await getFileThumbnailInformation(userId, id);
|
||||
return json(
|
||||
fileThumbnailInfoResponse.parse({ encContentIv } satisfies FileThumbnailInfoResponse),
|
||||
fileThumbnailInfoResponse.parse({
|
||||
updatedAt: updatedAt.toISOString(),
|
||||
encContentIv,
|
||||
} satisfies FileThumbnailInfoResponse),
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user