Skip to content

Commit

Permalink
fix(db): only create data directory if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
steveiliop56 committed Mar 23, 2024
1 parent 172e6ed commit 1864fc1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/server/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 1864fc1

Please sign in to comment.