Commit 25efc670 authored by nanahira's avatar nanahira

fix

parent aa0c242a
......@@ -115,8 +115,10 @@ export class DBReader extends Base {
cndb: Database;
outputdb: Database;
overrideTextDb: Database;
async openDatabase(path: string) {
await fs.access(path);
async openDatabase(path: string, mustExist: boolean = false) {
if (mustExist) {
await fs.access(path);
}
return await open({
filename: path,
driver: sqlite3.Database
......@@ -125,8 +127,8 @@ export class DBReader extends Base {
async init() {
await super.init();
this.log.debug(`Opening databases...`);
this.cndb = await this.openDatabase(this.config.cnDatabasePath);
this.jpdb = await this.openDatabase(this.config.jpDatabasePath);
this.cndb = await this.openDatabase(this.config.cnDatabasePath, true);
this.jpdb = await this.openDatabase(this.config.jpDatabasePath, true);
this.overrideTextDb = this.config.overrideTextDbPath ? await this.openDatabase(this.config.overrideTextDbPath) : null;
}
async finalize() {
......@@ -270,7 +272,7 @@ export class DBReader extends Base {
async getAllCardsFromDatabase(dbPath: string) {
try {
const db = await this.openDatabase(dbPath);
const db = await this.openDatabase(dbPath, true);
const codes: number[] = (await db.all('SELECT id FROM datas where type & 0x4000 = 0 and not exists (select 1 from datas orig where orig.id = datas.alias and orig.id < datas.id and orig.id >= (datas.id - 20))')).map(m => m.id);
await db.close();
return codes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment