From 6ddc4a771db23fe49d7a60736c85e7d25a862195 Mon Sep 17 00:00:00 2001 From: BurnyLlama Date: Thu, 4 Nov 2021 23:12:51 +0100 Subject: [PATCH] Fixed env mappings... --- libs/database/init.js | 4 ++-- libs/download/dowload.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/database/init.js b/libs/database/init.js index 0ec7408..737def0 100644 --- a/libs/database/init.js +++ b/libs/database/init.js @@ -21,8 +21,8 @@ export function dbInit() { log("Starting up databases...") /* load in db using better-sqlite3 */ - sqlite = new Database(process.env.DDNET_SQLITE_PATH ?? 'data/ddnet.sqlite', { }); - skinDB = new Database(process.env.DDNSS_SQLITE_PATH ?? 'data/skindata.sqlite', { }); + sqlite = new Database(process.env.DATA_DIR ? `${process.env.DATA_DIR}/ddnet.sqlite` : 'data/ddnet.sqlite', { }); + skinDB = new Database(process.env.DATA_DIR ? `${process.env.DATA_DIR}/skindata.sqlite` : 'data/skindata.sqlite', { }); /* WAL mode */ sqlite.pragma('journal_mode = WAL'); diff --git a/libs/download/dowload.js b/libs/download/dowload.js index 5addf4a..f3bebb1 100644 --- a/libs/download/dowload.js +++ b/libs/download/dowload.js @@ -60,14 +60,14 @@ export function downloadEssentialData() { (resolve, reject) => { log("Downloading 'ddnet.sqlite.zip' and 'players.msgpack'...") Promise.all([ - download("https://ddnet.tw/stats/ddnet.sqlite.zip", process.env.DDNET_SQLITE_PATH ? `${process.env.DDNET_SQLITE_PATH}.zip` : 'data/ddnet.sqlite.zip'), - download("https://ddnet.tw/players.msgpack", process.env.MSGPACK_PATH ?? 'data/players.msgpack') + download("https://ddnet.tw/stats/ddnet.sqlite.zip", process.env.DATA_DIR ? `${process.env.DATA_DIR}/ddnet.sqlite.zip` : 'data/ddnet.sqlite.zip'), + download("https://ddnet.tw/players.msgpack", process.env.DATA_DIR ? `${process.env.DATA_DIR}/players.msgpack` : 'data/players.msgpack') ]).then(() => { log("All downloads done! Going to unzip 'ddnet.sqlite.zip'...") exec( - `unzip -o ${process.env.DDNET_SQLITE_PATH ? `${process.env.DDNET_SQLITE_PATH}.zip` : 'data/ddnet.sqlite.zip'} \ - -d ${process.env.DDNET_SQLITE_PATH ? process.env.DDNET_SQLITE_PATH.replace(/\/[\s\S]*\.sqlite/, "") : 'data'}`, + `unzip -o ${process.env.DATA_DIR ? `${process.env.DATA_DIR}/ddnet.sqlite.zip` : 'data/ddnet.sqlite.zip'} \ + -d ${process.env.DATA_DIR ? process.env.DATA_DIR : 'data'}`, err => { if (err) { log("Error while unzipping!")