From c86c125feeb68c02945a45585d0d51a6ab2030d3 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 21 May 2023 20:29:56 +0800 Subject: [PATCH] Update --- db.ts | 12 ++++++++++-- deno.jsonc | 6 +++--- tasks/download.ts | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/db.ts b/db.ts index 3219ecc..28d0b61 100644 --- a/db.ts +++ b/db.ts @@ -1,6 +1,6 @@ import { DB } from "sqlite/mod.ts"; import { SemVer } from "std/semver/mod.ts"; -import { join } from "std/path/mod.ts"; +import { join, resolve } from "std/path/mod.ts"; import { SqliteError } from "sqlite/mod.ts"; import { Status } from "sqlite/src/constants.ts"; import { sleep, sure_dir_sync } from "./utils.ts"; @@ -155,7 +155,7 @@ export class EhDb { #lock_file: string | undefined; #dblock_file: string | undefined; #_tags: Map | undefined; - readonly version = new SemVer("1.0.0-1"); + readonly version = new SemVer("1.0.0-2"); constructor(base_path: string) { const db_path = join(base_path, "data.db"); sure_dir_sync(base_path); @@ -201,6 +201,14 @@ export class EhDb { this.db.execute("ALTER TABLE tag ADD translated TEXT;"); this.db.execute("ALTER TABLE tag ADD intro TEXT;"); } + if (v.compare("1.0.0-2") === -1) { + this.convert_file( + this.db.queryEntries("SELECT * FROM file;"), + ).forEach((f) => { + f.path = resolve(f.path); + this.add_file(f, false); + }); + } this.#write_version(); } if ( diff --git a/deno.jsonc b/deno.jsonc index 9083ef9..7124787 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -6,9 +6,9 @@ }, "tasks": { "dev": "deno run --watch main.ts", - "test": "deno test --allow-read=./config.json,./test --allow-net --allow-write=./test --allow-run=tasklist.exe --unstable", - "run": "deno run --allow-read=./config.json,./downloads --allow-write=./downloads --allow-run=tasklist.exe --allow-net --unstable", - "compile": "deno compile --allow-read=./config.json,./downloads --allow-write=./downloads --allow-run=tasklist.exe --allow-net --unstable", + "test": "deno test --allow-read=./ --allow-net --allow-write=./ --allow-run=tasklist.exe --unstable", + "run": "deno run --allow-read=./ --allow-write=./ --allow-run=tasklist.exe --allow-net --unstable", + "compile": "deno compile --allow-read=./ --allow-write=./ --allow-run=tasklist.exe --allow-net --unstable", "compile_full": "deno compile --allow-read --allow-write --allow-run=tasklist.exe --allow-net --unstable" }, "fmt": { diff --git a/tasks/download.ts b/tasks/download.ts index 574d60f..04256ca 100644 --- a/tasks/download.ts +++ b/tasks/download.ts @@ -10,7 +10,7 @@ import { sleep, sure_dir, } from "../utils.ts"; -import { join } from "std/path/mod.ts"; +import { join, resolve } from "std/path/mod.ts"; import { exists } from "std/fs/exists.ts"; class DownloadManager { @@ -111,7 +111,7 @@ export async function download_task( const download_original = cfg.download_original_img && !i.is_original; if (download_original) console.log(i.index, i.data.o); - const path = join(base_path, i.name); + const path = resolve(join(base_path, i.name)); function download_img() { return new Promise((resolve, reject) => { async function download() {