mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Stopped initial DB from being created when missing if config option set to false. Checked for existence of schema files before executing the schema.
This commit is contained in:
parent
97b2d2d561
commit
a8cbc4fbdb
1 changed files with 4 additions and 3 deletions
7
index.js
7
index.js
|
@ -21,7 +21,8 @@ YouTubeAPI.authenticate({
|
|||
var Sqlite3 = require('better-sqlite3');
|
||||
|
||||
let options = {
|
||||
readonly: config.readOnly
|
||||
readonly: config.readOnly,
|
||||
fileMustExist: !config.createDatabaseIfNotExist
|
||||
};
|
||||
|
||||
//load database
|
||||
|
@ -30,8 +31,8 @@ var db = new Sqlite3(config.db, options);
|
|||
var privateDB = new Sqlite3(config.privateDB, options);
|
||||
|
||||
if (config.createDatabaseIfNotExist && !config.readOnly) {
|
||||
db.exec(fs.readFileSync(config.dbSchema).toString());
|
||||
privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
|
||||
if (fs.existsSync(config.dbSchema)) db.exec(fs.readFileSync(config.dbSchema).toString());
|
||||
if (fs.existsSync(config.privateDBSchema)) privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
|
||||
}
|
||||
|
||||
// Create an HTTP service.
|
||||
|
|
Loading…
Reference in a new issue