Skip to content

Commit

Permalink
Fixed issue where config initialization did not occur early enough in…
Browse files Browse the repository at this point in the history
… lifecycle, causing db.js to throw an error if the config did not exist
  • Loading branch information
Tzahi12345 committed Jul 27, 2021
1 parent 7ff906f commit 7174ef5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const local_db_defaults = {}
tables_list.forEach(table => {local_db_defaults[table] = []});
local_db.defaults(local_db_defaults).write();

let using_local_db = config_api.getConfigItem('ytdl_use_local_db');
let using_local_db = null;

function setDB(input_db, input_users_db) {
db = input_db; users_db = input_users_db;
Expand All @@ -69,6 +69,9 @@ function setLogger(input_logger) {
exports.initialize = (input_db, input_users_db, input_logger) => {
setDB(input_db, input_users_db);
setLogger(input_logger);

// must be done here to prevent getConfigItem from being called before init
using_local_db = config_api.getConfigItem('ytdl_use_local_db');
}

exports.connectToDB = async (retries = 5, no_fallback = false) => {
Expand Down

0 comments on commit 7174ef5

Please sign in to comment.