Added recovery feature
If the database get corrupted, the admin can restore it through the website.
This commit is contained in:
@@ -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.");
|
||||
|
||||
+9
-4
@@ -12,13 +12,18 @@
|
||||
href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap"
|
||||
rel="stylesheet">
|
||||
<link rel="stylesheet" href="<%= css_path %>">
|
||||
<script src="<%= js_path %>" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="control_div">
|
||||
<label
|
||||
style='font-family: "Ubuntu", sans-serif; font-weight: 500; font-style: normal; font-size: 200%;'>CRTelemetry
|
||||
SQLite3</label>
|
||||
<input type="file" id="file_input" accept=".db" style="display: none;" />
|
||||
<div class="control_div" style="display: flex; flex-direction: row; justify-content: space-between;">
|
||||
<label style="font-size: 200%;">CRTelemetry SQLite3</label>
|
||||
<div style="display: flex;align-items: center;">
|
||||
<label id="upload" style="cursor: pointer; margin-left: 10px; margin-right: 10px;"><span>🡅 </span>Upload</label>
|
||||
<label id="download" style="cursor: pointer; margin-left: 10px; margin-right: 10px;"><span>🡇 </span>Download</label>
|
||||
<label id="logout" style="cursor: pointer; margin-left: 10px;"><span>🡄 </span>Logout</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main_div">
|
||||
<label style="font-size: 150%;">
|
||||
|
||||
Reference in New Issue
Block a user