From fe34703caaf071b9295c4a792b0abf4e36f649ea Mon Sep 17 00:00:00 2001 From: rdbrschf <54837367+rdbrschf@users.noreply.github.com> Date: Wed, 30 Aug 2023 00:51:17 +0200 Subject: [PATCH] backend/nile: handle update requests for empty installed game list gracefully. If no game is installed, nile list-updates will return an empty string. Unfortunately, this is not valid JSON and JSON.parse() later bails out with an error. We're good to go if no game is installed either way, so break out early and don't try to parse an empty string. --- src/backend/storeManagers/nile/library.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/storeManagers/nile/library.ts b/src/backend/storeManagers/nile/library.ts index c31269e697..8810cf4acb 100644 --- a/src/backend/storeManagers/nile/library.ts +++ b/src/backend/storeManagers/nile/library.ts @@ -166,6 +166,14 @@ export async function listUpdateableGames(): Promise { ) deleteAbortController(abortID) + if (!output) { + /* + * Nothing installed: nothing to update, output will be empty and JSON.parse can't + * handle empty strings (they aren't proper JSON). + */ + return [] + } + const updates: string[] = JSON.parse(output) if (updates.length) { logInfo(['Found', `${updates.length}`, 'games to update'], LogPrefix.Nile)