move startup script check where it belongs

At reader startup, so the intended use case is correctly handled:
- an update is downloaded, and the user restarts KOReader
- the LuaJIT process returns control to the startup script which extracts the update
- the LuaJIT process is restarted, and if the startup script was changed, the user
  is asked to quit and restart KOReader from the parent launcher
This commit is contained in:
Benoit Pierre authored and Frans de Jonge committed 2026-01-06 21:26:30 +01:00
1 parent 0b53cefb9f
commit 4186cde33a
4 files changed
+37 -44

No files matched your search

@@ -999,18 +999,6 @@ function FileManagerMenu:getStartWithMenuTable()
end
function FileManagerMenu:exitOrRestart(callback, force)
-- Only restart sets a callback, which suits us just fine for this check ;)
if callback and not force and not Device:isStartupScriptUpToDate() then
UIManager:show(ConfirmBox:new{
text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."),
ok_text = _("Restart anyway"),
ok_callback = function()
self:exitOrRestart(callback, true)
end,
})
return
end
UIManager:close(self.menu_container)
self.ui:onClose()
if callback then
@@ -402,18 +402,6 @@ function ReaderMenu:saveDocumentSettingsAsDefault()
end
function ReaderMenu:exitOrRestart(callback, force)
-- Only restart sets a callback, which suits us just fine for this check ;)
if callback and not force and not Device:isStartupScriptUpToDate() then
UIManager:show(ConfirmBox:new{
text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."),
ok_text = _("Restart anyway"),
ok_callback = function()
self:exitOrRestart(callback, true)
end,
})
return
end
self:onTapCloseMenu()
UIManager:nextTick(function()
self.ui:onClose()
+3 -1
View File
@@ -854,7 +854,9 @@ function UIManager:unsetRunForeverMode()
self._gated_quit = function() return self:quit(nil, true) end
end
-- Ignore an empty window stack *once*; for startup w/ a missing last_file shenanigans...
-- We'll want to return from this without actually quitting, so this is
-- a slightly mangled UIManager:run() call to coerce the main loop into
-- submission to ignore an empty window stack *once*.
function UIManager:runOnce()
-- We don't actually want to call self.quit, and we need to deal with a bit of trickery in there anyway...
self._gated_quit = function()
+34 -19
View File
@@ -212,31 +212,30 @@ if G_reader_settings:isTrue("color_rendering") and not Device:hasColorScreen() t
UIManager:broadcastEvent(Event:new("ColorRenderingUpdate"))
end,
})
-- This will only return once the user has made a choice.
UIManager:runOnce()
end
-- Get which file to start with
local last_file = G_reader_settings:readSetting("lastfile")
local start_with = G_reader_settings:readSetting("start_with") or "filemanager"
local exit_code
-- Helpers
local function retryLastFile()
if not Device:isStartupScriptUpToDate() then
local ConfirmBox = require("ui/widget/confirmbox")
return ConfirmBox:new{
text = _("Cannot open last file.\nThis could be because it was deleted or because external storage is still being mounted.\nDo you want to retry?"),
UIManager:show(ConfirmBox:new{
text = _("KOReader's startup script has been updated. You'll need to completely exit KOReader to finalize the update."),
cancel_text = _("Ignore"),
ok_text = _("Quit"),
ok_callback = function()
if lfs.attributes(last_file, "mode") ~= "file" then
UIManager:show(retryLastFile())
end
exit_code = 0
end,
cancel_callback = function()
start_with = "filemanager"
end,
}
})
-- This will only return once the user has made a choice.
UIManager:runOnce()
end
-- Start app
local exit_code
if file then
if exit_code then -- luacheck: ignore
-- We're quitting to finalize an update.
elseif file then
local ReaderUI = require("apps/reader/readerui")
ReaderUI:showReader(file)
exit_code = UIManager:run()
@@ -245,6 +244,10 @@ elseif directory then
FileManager:showFiles(directory)
exit_code = UIManager:run()
else
-- Get which file to start with
local last_file = G_reader_settings:readSetting("lastfile")
local start_with = G_reader_settings:readSetting("start_with") or "filemanager"
local QuickStart = require("ui/quickstart")
if not QuickStart:isShown() then
start_with = "last"
@@ -252,10 +255,22 @@ else
end
if start_with == "last" and last_file and lfs.attributes(last_file, "mode") ~= "file" then
local function retryLastFile()
local ConfirmBox = require("ui/widget/confirmbox")
return ConfirmBox:new{
text = _("Cannot open last file.\nThis could be because it was deleted or because external storage is still being mounted.\nDo you want to retry?"),
ok_callback = function()
if lfs.attributes(last_file, "mode") ~= "file" then
UIManager:show(retryLastFile())
end
end,
cancel_callback = function()
start_with = "filemanager"
end,
}
end
UIManager:show(retryLastFile())
-- We'll want to return from this without actually quitting,
-- so this is a slightly mangled UIManager:run() call to coerce the main loop into submission...
-- We'll call :run properly in either of the following branches once returning.
-- This will only return once the file is available or the user gave up.
UIManager:runOnce()
end
if start_with == "last" and last_file then