This commit is contained in:
furo 2021-11-04 23:17:51 +01:00
commit 823f035a45
2 changed files with 6 additions and 6 deletions

View File

@ -21,8 +21,8 @@ export function dbInit() {
log("Starting up databases...") log("Starting up databases...")
/* load in db using better-sqlite3 */ /* load in db using better-sqlite3 */
sqlite = new Database(process.env.DDNET_SQLITE_PATH ?? 'data/ddnet.sqlite', { }); sqlite = new Database(process.env.DATA_DIR ? `${process.env.DATA_DIR}/ddnet.sqlite` : 'data/ddnet.sqlite', { });
skinDB = new Database(process.env.DDNSS_SQLITE_PATH ?? 'data/skindata.sqlite', { }); skinDB = new Database(process.env.DATA_DIR ? `${process.env.DATA_DIR}/skindata.sqlite` : 'data/skindata.sqlite', { });
/* WAL mode */ /* WAL mode */
sqlite.pragma('journal_mode = WAL'); sqlite.pragma('journal_mode = WAL');

View File

@ -60,14 +60,14 @@ export function downloadEssentialData() {
(resolve, reject) => { (resolve, reject) => {
log("Downloading 'ddnet.sqlite.zip' and 'players.msgpack'...") log("Downloading 'ddnet.sqlite.zip' and 'players.msgpack'...")
Promise.all([ 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/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.MSGPACK_PATH ?? 'data/players.msgpack') download("https://ddnet.tw/players.msgpack", process.env.DATA_DIR ? `${process.env.DATA_DIR}/players.msgpack` : 'data/players.msgpack')
]).then(() => { ]).then(() => {
log("All downloads done! Going to unzip 'ddnet.sqlite.zip'...") log("All downloads done! Going to unzip 'ddnet.sqlite.zip'...")
exec( exec(
`unzip -o ${process.env.DDNET_SQLITE_PATH ? `${process.env.DDNET_SQLITE_PATH}.zip` : 'data/ddnet.sqlite.zip'} \ `unzip -o ${process.env.DATA_DIR ? `${process.env.DATA_DIR}/ddnet.sqlite.zip` : 'data/ddnet.sqlite.zip'} \
-d ${process.env.DDNET_SQLITE_PATH ? process.env.DDNET_SQLITE_PATH.replace(/\/[\s\S]*\.sqlite/, "") : 'data'}`, -d ${process.env.DATA_DIR ? process.env.DATA_DIR : 'data'}`,
err => { err => {
if (err) { if (err) {
log("Error while unzipping!") log("Error while unzipping!")