mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
NetworkManager: Plug a logic hole in the beforeWifiAction logic
The *runWhenOnline wrappers may not pass a callback when connected but not online yet, so we need nil guards all the way down ;). Re: #10806
This commit is contained in:
@@ -322,8 +322,12 @@ end
|
||||
function NetworkMgr:turnOnWifiAndWaitForConnection(callback)
|
||||
-- Just run the callback if WiFi is already up...
|
||||
if self:isWifiOn() and self:isConnected() then
|
||||
-- Given the guards in beforeWifiAction callers, this shouldn't really ever happen...
|
||||
callback()
|
||||
--- @note: beforeWifiAction only guarantees isConnected, not isOnline.
|
||||
-- In the rare cases we're isConnected but !isOnline, if we're called via a *runWhenOnline wrapper,
|
||||
-- we don't get a callback at all to avoid infinite recursion, so we need to check it.
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user