From 788606ae7d49d3227852e4fdaf9e033d6c95ace7 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 10 Dec 2023 17:38:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20/api/files/token=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db.ts b/db.ts index 3578c41..9412fb4 100644 --- a/db.ts +++ b/db.ts @@ -234,6 +234,7 @@ const FILE_TABLE = `CREATE TABLE file ( height INT, is_original BOOLEAN );`; +const FILE_INDEX = `CREATE INDEX file_token ON file (token);`; const FILEMETA_TABLE = `CREATE TABLE filemeta ( token TEXT, is_nsfw BOOLEAN, @@ -272,7 +273,7 @@ export class EhDb { #lock_file: string | undefined; #dblock_file: string | undefined; #_tags: Map | undefined; - readonly version = parse_ver("1.0.0-9"); + readonly version = parse_ver("1.0.0-10"); constructor(base_path: string) { const db_path = join(base_path, "data.db"); sure_dir_sync(base_path); @@ -407,6 +408,9 @@ export class EhDb { this.db.execute("ALTER TABLE token ADD secure BOOLEAN;"); this.db.execute("UPDATE token SET http_only = 1, secure = 0;"); } + if (compare_ver(v, parse_ver("1.0.0-10")) === -1) { + this.db.execute(FILE_INDEX); + } this.#write_version(); if (need_optimize) this.optimize(); } @@ -438,6 +442,7 @@ export class EhDb { } if (!this.#exist_table.has("file")) { this.db.execute(FILE_TABLE); + this.db.execute(FILE_INDEX); } if (!this.#exist_table.has("filemeta")) { this.db.execute(FILEMETA_TABLE);