This commit is contained in:
2023-05-21 20:29:56 +08:00
parent 022c98dec7
commit c86c125fee
3 changed files with 15 additions and 7 deletions

12
db.ts
View File

@@ -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<string, number> | 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<EhFileRaw>("SELECT * FROM file;"),
).forEach((f) => {
f.path = resolve(f.path);
this.add_file(f, false);
});
}
this.#write_version();
}
if (

View File

@@ -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": {

View File

@@ -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<void>((resolve, reject) => {
async function download() {