mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Kobo: Warn on restart if the startup script is outdated (#6916)
* Warn on restart if the startup script has been updated, because a restart will not reload it. * Also warn right after the update if it contained a startup script update...
This commit is contained in:
@@ -565,8 +565,21 @@ dbg:guard(FileManagerMenu, 'setUpdateItemTable',
|
||||
end
|
||||
end)
|
||||
|
||||
function FileManagerMenu:exitOrRestart(callback)
|
||||
function FileManagerMenu:exitOrRestart(callback, force)
|
||||
UIManager:close(self.menu_container)
|
||||
|
||||
-- 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.ui:onClose()
|
||||
if callback then
|
||||
callback()
|
||||
|
||||
@@ -259,8 +259,21 @@ dbg:guard(ReaderMenu, 'setUpdateItemTable',
|
||||
end
|
||||
end)
|
||||
|
||||
function ReaderMenu:exitOrRestart(callback)
|
||||
function ReaderMenu:exitOrRestart(callback, force)
|
||||
if self.menu_container then self:onTapCloseMenu() end
|
||||
|
||||
-- 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:nextTick(function()
|
||||
self.ui:onClose()
|
||||
if callback ~= nil then
|
||||
|
||||
@@ -491,4 +491,9 @@ function Device:isValidPath(path)
|
||||
return util.pathExists(path)
|
||||
end
|
||||
|
||||
-- Device specific method to check if the startup script has been updated
|
||||
function Device:isStartupScriptUpToDate()
|
||||
return true
|
||||
end
|
||||
|
||||
return Device
|
||||
|
||||
@@ -819,6 +819,15 @@ function Kobo:toggleChargingLED(toggle)
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
function Kobo:isStartupScriptUpToDate()
|
||||
-- Compare the hash of the *active* script (i.e., the one in /tmp) to the *potential* one (i.e., the one in KOREADER_DIR)
|
||||
local current_script = "/tmp/koreader.sh"
|
||||
local new_script = os.getenv("KOREADER_DIR") .. "/" .. "koreader.sh"
|
||||
|
||||
local md5 = require("ffi/MD5")
|
||||
return md5.sumFile(current_script) == md5.sumFile(new_script)
|
||||
end
|
||||
|
||||
-------------- device probe ------------
|
||||
|
||||
local codename = Kobo:getCodeName()
|
||||
|
||||
@@ -100,6 +100,11 @@ ko_update_check() {
|
||||
mv "${NEWUPDATE}" "${INSTALLED}"
|
||||
./fbink -q -y -6 -pm "Update successful :)"
|
||||
./fbink -q -y -5 -pm "KOReader will start momentarily . . ."
|
||||
|
||||
# Warn if the startup script has been updated...
|
||||
if [ "$(md5sum "/tmp/koreader.sh" | cut -f1 -d' ')" != "$(md5sum "${KOREADER_DIR}/koreader.sh" | cut -f1 -d' ')" ]; then
|
||||
./fbink -q -pmMh "Update contains a startup script update!"
|
||||
fi
|
||||
else
|
||||
# Uh oh...
|
||||
./fbink -q -y -6 -pmh "Update failed :("
|
||||
|
||||
Reference in New Issue
Block a user