diff --git a/server/database.js b/server/database.js index 7deea83d2..42d642794 100644 --- a/server/database.js +++ b/server/database.js @@ -3,6 +3,7 @@ const { R } = require("redbean-node"); const { setSetting, setting } = require("./util-server"); const { log, sleep } = require("../src/util"); const knex = require("knex"); +const path = require("path"); /** * Database & App Data Folder @@ -94,19 +95,19 @@ class Database { // Data Directory (must be end with "/") Database.dataDir = process.env.DATA_DIR || args["data-dir"] || "./data/"; - Database.path = Database.dataDir + "kuma.db"; + Database.path = path.join(Database.dataDir, "kuma.db"); if (! fs.existsSync(Database.dataDir)) { fs.mkdirSync(Database.dataDir, { recursive: true }); } - Database.uploadDir = Database.dataDir + "upload/"; + Database.uploadDir = path.join(Database.dataDir, "upload/"); if (! fs.existsSync(Database.uploadDir)) { fs.mkdirSync(Database.uploadDir, { recursive: true }); } // Create screenshot dir - Database.screenshotDir = Database.dataDir + "screenshots/"; + Database.screenshotDir = path.join(Database.dataDir, "screenshots/"); if (! fs.existsSync(Database.screenshotDir)) { fs.mkdirSync(Database.screenshotDir, { recursive: true }); } diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 6781488e5..7817c9e1c 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -11,6 +11,7 @@ const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent"); const { Settings } = require("./settings"); const dayjs = require("dayjs"); const childProcess = require("child_process"); +const path = require("path"); // DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead. /** @@ -214,7 +215,7 @@ class UptimeKumaServer { * @param {boolean} outputToConsole Should the error also be output to console? */ static errorLog(error, outputToConsole = true) { - const errorLogStream = fs.createWriteStream(Database.dataDir + "/error.log", { + const errorLogStream = fs.createWriteStream(path.join(Database.dataDir, "/error.log"), { flags: "a" });