diff --git a/app/routes/private_routes.js b/app/routes/private_routes.js index 3925ba9..cd39cbc 100644 --- a/app/routes/private_routes.js +++ b/app/routes/private_routes.js @@ -48,9 +48,16 @@ router.get("/enable", async (req, res) => { router.delete("/remove", async (req, res) => { logger.info(`${req.method}: "${req.url}" => ${req.get("User-Agent")}`); - if (req.query["element"]) { + var element = req.query["element"]; + if (element) { try { - fs.unlinkSync(path.join(path.dirname(require.main.filename), map_conf.map_storage_path, req.query["element"])); + fs.unlinkSync(path.join(path.dirname(require.main.filename), map_conf.map_storage_path, element)); + if (fs.existsSync(path.join(path.dirname(require.main.filename), map_conf.map_storage_path, "selected"))) { + selected_map_name = fs.readFileSync(path.join(path.dirname(require.main.filename), map_conf.map_storage_path, "selected"), "utf-8"); + if (selected_map_name == element) { + fs.unlinkSync(path.join(path.dirname(require.main.filename), map_conf.map_storage_path, "selected")); + } + } res.status(200).send(); } catch (error) { res.status(500).send();