From def14344e387f51cf56cae9a9d46cfa6a3ba13cd Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Sat, 9 Sep 2023 19:21:49 +0530 Subject: [PATCH] Fix #452 --- electron/index.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/electron/index.ts b/electron/index.ts index 5213a69..5b09b72 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -467,7 +467,13 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => { if (fs.existsSync(outFile) && overwrite === false) { // If already upscayled, just output that file logit("✅ Already upscayled at: ", outFile); - mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile); + mainWindow.webContents.send( + commands.UPSCAYL_DONE, + outFile.replace( + /([^/\\]+)$/i, + encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]) + ) + ); } else { const upscayl = spawnUpscayl( "realesrgan", @@ -532,7 +538,13 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => { onError ); mainWindow.setProgressBar(-1); - mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile); + mainWindow.webContents.send( + commands.UPSCAYL_DONE, + outFile.replace( + /([^/\\]+)$/i, + encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]) + ) + ); } catch (error) { logit( "❌ Error processing (scaling and converting) the image. Please report this error on GitHub.", @@ -819,7 +831,15 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => { mainWindow.setProgressBar(-1); mainWindow.webContents.send( commands.DOUBLE_UPSCAYL_DONE, - isAlpha ? outFile + ".png" : outFile + isAlpha + ? (outFile + ".png").replace( + /([^/\\]+)$/i, + encodeURIComponent((outFile + ".png").match(/[^/\\]+$/i)![0]) + ) + : outFile.replace( + /([^/\\]+)$/i, + encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]) + ) ); } catch (error) { logit("❌ Error reading original image metadata", error);