From 1864fc16e6e5e7344094c388a4f7aa577397628d Mon Sep 17 00:00:00 2001 From: Stavros Date: Sat, 23 Mar 2024 19:31:43 +0200 Subject: [PATCH] fix(db): only create data directory if it doesn't exist --- src/server/db/db.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server/db/db.ts b/src/server/db/db.ts index b932223..e9c094b 100644 --- a/src/server/db/db.ts +++ b/src/server/db/db.ts @@ -8,11 +8,15 @@ import * as fs from "fs"; if (fs.existsSync("sqlite.db")) { console.log("DB not in data directory! Moving..."); - fs.mkdirSync("data"); + if (!fs.existsSync("data")) { + fs.mkdirSync("data"); + } fs.renameSync("sqlite.db", "data/sqlite.db"); } else if (!fs.existsSync("data/sqlite.db") && !fs.existsSync("sqlite.db")) { console.log("Couldn't find DB copying from assets..."); - fs.mkdirSync("data"); + if (!fs.existsSync("data")) { + fs.mkdirSync("data"); + } fs.copyFileSync("assets/sqlite.db", "data/sqlite.db"); }