diff --git a/src/bun/api/jobs/self-update-job.ts b/src/bun/api/jobs/self-update-job.ts index 38d57c0..f965311 100644 --- a/src/bun/api/jobs/self-update-job.ts +++ b/src/bun/api/jobs/self-update-job.ts @@ -48,6 +48,10 @@ export default class SelfUpdateJob implements IJob { case "win32": validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.zip`).match(e.name)); + if (!validAsset) + { + validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-*.zip`).match(e.name)); + } break; case "linux": validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.AppImage`).match(e.name)); @@ -100,13 +104,13 @@ export default class SelfUpdateJob implements IJob const batPath = path.join(os.tmpdir(), "update-gameflow.bat"); await Bun.write(batPath, mustache.render(winUpdateScript, { tempFile: winDownloads[0], - extractDir: path.dirname(process.execPath), + installDir: path.dirname(process.execPath), + extractDir: path.join(os.tmpdir(), 'gameflow-update-extract'), exePath: `${pkg.bin}.exe` })); context.setProgress(0, "Restarting App To Update"); - await cleanup(); events.emit('exitapp'); - Bun.spawn(["cmd", "/c", batPath], { detached: true }); + Bun.spawn(["cmd", "/c", "start", "cmd", "/c", batPath], { detached: true }); process.exit(0); } diff --git a/src/bun/utils/update-gameflow-linux.sh b/src/bun/utils/update-gameflow-linux.sh index 1bd1c81..9fc68cf 100644 --- a/src/bun/utils/update-gameflow-linux.sh +++ b/src/bun/utils/update-gameflow-linux.sh @@ -1,6 +1,9 @@ #!/bin/bash +echo "Waiting for app to close..." sleep 2 +echo "Installing update..." mv "{{{tempFile}}}" "{{{appImagePath}}}" chmod +x "{{{appImagePath}}}" +echo "Done! Restarting..." "{{{appImagePath}}}" & rm -- "$0" \ No newline at end of file diff --git a/src/bun/utils/update-gameflow-windows.bat b/src/bun/utils/update-gameflow-windows.bat index 11dc3c8..67b8ee8 100644 --- a/src/bun/utils/update-gameflow-windows.bat +++ b/src/bun/utils/update-gameflow-windows.bat @@ -1,6 +1,19 @@ @echo off +echo Waiting for app to close... timeout /t 2 /nobreak -powershell -Command "Expand-Archive -Force '{{{tempFile}}}' '{{{installDir}}}'" +echo. +if exist "{{{extractDir}}}" ( + echo Cleaning up previous update files... + rmdir /S /Q "{{{extractDir}}}" +) +echo Extracting update... +mkdir "{{{extractDir}}}" +tar -xf "{{{tempFile}}}" -C "{{{extractDir}}}" +echo Installing update... +for /d %%i in ("{{{extractDir}}}\*") do xcopy /E /Y /I "%%i\*" "{{{installDir}}}\" >nul +echo Cleaning up... +rmdir /S /Q "{{{extractDir}}}" del "{{{tempFile}}}" +echo Done! Restarting... start "" /D "{{{installDir}}}" "{{{exePath}}}" del "%~f0" \ No newline at end of file