add guards for file backup

This commit is contained in:
FinnHornhoover 2024-06-07 11:46:01 +03:00
parent 7f9c5d90a1
commit 16a158906d

View File

@ -34,10 +34,10 @@ function initialSetup(firstTime) {
if (!firstTime) { if (!firstTime) {
// Migration from pre-1.6 // Migration from pre-1.6
// Back everything up, just in case // Back everything up, just in case
fs.copySync(configPath, configPath + ".bak"); if (fs.existsSync(configPath)) fs.copySync(configPath, configPath + ".bak");
fs.copySync(serversPath, serversPath + ".bak"); if (fs.existsSync(serversPath)) fs.copySync(serversPath, serversPath + ".bak");
fs.copySync(versionsPath, versionsPath + ".bak"); if (fs.existsSync(versionsPath)) fs.copySync(versionsPath, versionsPath + ".bak");
fs.copySync(hashPath, hashPath + ".bak"); if (fs.existsSync(hashPath)) fs.copySync(hashPath, hashPath + ".bak");
} else { } else {
// First-time setup // First-time setup
// Copy default servers // Copy default servers