From 7d07aa29aa959e389d81ff4dbee308680f1204f0 Mon Sep 17 00:00:00 2001 From: carlkuesters Date: Sun, 5 Jun 2022 18:20:53 +0200 Subject: [PATCH] Fix crash when app directory wasn't existing yet for new apps. --- package-lock.json | 2 +- package.json | 2 +- src/main/local-apps.js | 15 +++++++++++---- src/package.json | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index dccfa50..e879a2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "destrostudios", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9a5c41d..bd9d9f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "destrostudios", - "version": "1.3.0", + "version": "1.3.1", "description": "destrostudios cross-game launcher, offering the possibility to login, download, update and start games.", "author": "destrostudios", "license": "MIT", diff --git a/src/main/local-apps.js b/src/main/local-apps.js index 493e7cc..f202484 100644 --- a/src/main/local-apps.js +++ b/src/main/local-apps.js @@ -21,17 +21,24 @@ function compareAppFiles(event, app, appFilesResponse, userDataPath) { }); } -function getAllFilePaths(baseDirectory, directoryPath, dest = []) { +function getAllFilePaths(baseDirectory, directoryPath) { + const filePaths = []; + if (fs.existsSync(baseDirectory + directoryPath)) { + addAllFilePaths(baseDirectory, directoryPath, filePaths); + } + return filePaths; +} + +function addAllFilePaths(baseDirectory, directoryPath, dest) { const files = fs.readdirSync(baseDirectory + directoryPath) files.forEach(file => { const filePath = directoryPath + file; if (fs.statSync(baseDirectory + filePath).isDirectory()) { - getAllFilePaths(baseDirectory, filePath + '/', dest); + addAllFilePaths(baseDirectory, filePath + '/', dest); } else { dest.push(filePath); } - }) - return dest; + }); } function checkNextLocalFileForDeletion(localFilePaths, appFilesResponse, currentFileIndex, shouldBeDeletedCallback, finishedCallback) { diff --git a/src/package.json b/src/package.json index d7d479e..9b4c8f1 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "destrostudios", - "version": "1.3.0", + "version": "1.3.1", "description": "Destrostudios cross-game launcher, offering the possibility to login, download, update and start games.", "author": "destrostudios", "main": "electron-main.js",