From afc5e30d802387d138c2cc898f322d9fc32250d4 Mon Sep 17 00:00:00 2001 From: bryanthaboi Date: Tue, 29 Sep 2026 20:01:49 -0400 Subject: [PATCH] perhaps a windows fix --- main.lua | 4 ++++ src/core/HostShell.lua | 12 ++++++++++++ src/update/Boot.lua | 23 ++++++++++++++++++++--- src/update/check_worker.lua | 7 +++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index d6eb4fa2..adf21571 100644 --- a/main.lua +++ b/main.lua @@ -1543,6 +1543,10 @@ local quitToLauncher = false function love.quit() if launcherSplash then launcherSplash:release(); launcherSplash = nil end + if Importer and Importer._themeVideo then + pcall(Importer._themeVideo.release, Importer._themeVideo) + Importer._themeVideo = nil + end if Importer then require("src.import.LauncherWindow").observe(0) require("src.import.LauncherWindow").flush() diff --git a/src/core/HostShell.lua b/src/core/HostShell.lua index f32fda73..54b14421 100644 --- a/src/core/HostShell.lua +++ b/src/core/HostShell.lua @@ -295,6 +295,18 @@ function HostShell.restart() return end + if osName == "Windows" then + local exe = love.filesystem.isFused and love.filesystem.isFused() + and love.filesystem.getSource() + if exe and exe ~= "" then + local cmd = 'start "" "' .. exe:gsub("/", "\\") .. '"' + if os.execute(cmd) then + love.event.quit() + return + end + end + end + love.event.quit("restart") end diff --git a/src/update/Boot.lua b/src/update/Boot.lua index 15646f77..ef4f495f 100644 --- a/src/update/Boot.lua +++ b/src/update/Boot.lua @@ -186,6 +186,19 @@ function Boot.select(candidates, bundledEngine, bundledShell, bundledPayloadHost return chosen and chosen.name or nil, toDelete end +local function badMarker(name) + return PAYLOAD_DIR .. "/" .. name .. ".bad" +end + +local function markBad(name, err) + love.filesystem.createDirectory(PAYLOAD_DIR) + love.filesystem.write(badMarker(name), tostring(err)) +end + +function Boot.isBad(name) + return love.filesystem.getInfo(badMarker(name)) ~= nil +end + -- Mount the chosen payload and hand control to it. Returns true when the -- payload is live and has completed its own love.load; false (with full -- rollback) on any failure, so the caller runs the bundled game instead. @@ -224,11 +237,13 @@ local function chainload(name, args) -- Delete the payload too: it failed deterministically once, so leaving it -- would re-select and re-fail it on every boot forever. print("update: payload handoff failed, reverting to bundled: " .. tostring(err)) + pcall(love.filesystem.append, PAYLOAD_DIR .. "/handoff.log", + name .. ": " .. tostring(err) .. "\n") _G.POKEPORT_PAYLOAD_MOUNTED = nil pcall(love.filesystem.unmount, rel) purgeBundledModules() restoreCallbacks(snapshot) - love.filesystem.remove(rel) + if not love.filesystem.remove(rel) then markBad(name, err) end love.filesystem.remove(PENDING) return false end @@ -250,7 +265,9 @@ local function runInner(args) if pending then pending = pending:gsub("%s+$", "") if pending ~= "" then - love.filesystem.remove(PAYLOAD_DIR .. "/" .. pending) + if not love.filesystem.remove(PAYLOAD_DIR .. "/" .. pending) then + markBad(pending, "crash during handoff") + end end love.filesystem.remove(PENDING) end @@ -259,7 +276,7 @@ local function runInner(args) local candidates = {} if love.filesystem.getInfo(PAYLOAD_DIR, "directory") then for _, entry in ipairs(love.filesystem.getDirectoryItems(PAYLOAD_DIR)) do - if isPayloadName(entry) then + if isPayloadName(entry) and not Boot.isBad(entry) then local info = Boot.probePayload(PAYLOAD_DIR .. "/" .. entry) if info then candidates[#candidates + 1] = { diff --git a/src/update/check_worker.lua b/src/update/check_worker.lua index 62c6402c..714433e4 100644 --- a/src/update/check_worker.lua +++ b/src/update/check_worker.lua @@ -267,6 +267,13 @@ local function doCheck(target) -- Already downloaded on a previous run? Verify and gate it rather than -- pulling the bytes again. local finalRel = "updates/" .. rel.payloadName + if Boot and Boot.isBad and Boot.isBad(rel.payloadName) then + if love.filesystem.getInfo(finalRel) and not love.filesystem.remove(finalRel) then + postFullRequirement(rel, "payload_failed") + return + end + love.filesystem.remove(finalRel .. ".bad") + end if love.filesystem.getInfo(finalRel) then local sums = fetchText(rel.sums.url) if sums and verifyPayload(finalRel, rel.payloadName, sums) then