Added recovery feature

If the database get corrupted, the admin can restore it through the website.
This commit is contained in:
2025-05-15 13:58:50 +03:00
parent 9adb9a4068
commit e21ba3e213
3 changed files with 57 additions and 7 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
const db = require("../database/sqlite.database.js");
var db = require("../database/sqlite.database.js");
const logger = require("../utils/logger.util.js");
const Database = require("better-sqlite3");
const path = require("path");
@@ -13,6 +13,7 @@ function errorPageRenderer(res, emoji, message) {
res.render("error", {
page_title: app_conf.name,
css_path: path.join(app_conf.paths.css.web, "stylesheet.css"),
js_path: path.join(app_conf.paths.js.web, "error.js"),
error_emoji: emoji,
error_message: message
})
@@ -51,8 +52,6 @@ router.post("/upload", async (req, res) => {
db = new Database(db_conf.path, { fileMustExist: true });
} catch (error) {
logger.error(error);
shutting_down = true;
shutdown();
}
}
});
@@ -240,6 +239,7 @@ router.get("/edit", async (req, res) => {
}
} catch (error) {
logger.error(error.message);
errorPageRenderer(res, "🌋💥", "Internal server error. Check logs for more information.");
}
} else {
errorPageRenderer(res, "✋⛔", "Bad request.");