From 16a158906d663017ab9afa06cdc056c18f31e3e2 Mon Sep 17 00:00:00 2001 From: FinnHornhoover Date: Fri, 7 Jun 2024 11:46:01 +0300 Subject: [PATCH] add guards for file backup --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2aada44..db71df1 100644 --- a/index.js +++ b/index.js @@ -34,10 +34,10 @@ function initialSetup(firstTime) { if (!firstTime) { // Migration from pre-1.6 // Back everything up, just in case - fs.copySync(configPath, configPath + ".bak"); - fs.copySync(serversPath, serversPath + ".bak"); - fs.copySync(versionsPath, versionsPath + ".bak"); - fs.copySync(hashPath, hashPath + ".bak"); + if (fs.existsSync(configPath)) fs.copySync(configPath, configPath + ".bak"); + if (fs.existsSync(serversPath)) fs.copySync(serversPath, serversPath + ".bak"); + if (fs.existsSync(versionsPath)) fs.copySync(versionsPath, versionsPath + ".bak"); + if (fs.existsSync(hashPath)) fs.copySync(hashPath, hashPath + ".bak"); } else { // First-time setup // Copy default servers