mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 14:37:17 +03: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:
7
index.js
7
index.js
@@ -21,7 +21,8 @@ YouTubeAPI.authenticate({
|
|||||||
var Sqlite3 = require('better-sqlite3');
|
var Sqlite3 = require('better-sqlite3');
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
readonly: config.readOnly
|
readonly: config.readOnly,
|
||||||
|
fileMustExist: !config.createDatabaseIfNotExist
|
||||||
};
|
};
|
||||||
|
|
||||||
//load database
|
//load database
|
||||||
@@ -30,8 +31,8 @@ var db = new Sqlite3(config.db, options);
|
|||||||
var privateDB = new Sqlite3(config.privateDB, options);
|
var privateDB = new Sqlite3(config.privateDB, options);
|
||||||
|
|
||||||
if (config.createDatabaseIfNotExist && !config.readOnly) {
|
if (config.createDatabaseIfNotExist && !config.readOnly) {
|
||||||
db.exec(fs.readFileSync(config.dbSchema).toString());
|
if (fs.existsSync(config.dbSchema)) db.exec(fs.readFileSync(config.dbSchema).toString());
|
||||||
privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
|
if (fs.existsSync(config.privateDBSchema)) privateDB.exec(fs.readFileSync(config.privateDBSchema).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an HTTP service.
|
// Create an HTTP service.
|
||||||
|
|||||||
Reference in New Issue
Block a user