1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Move values the mainmenu caches to dedicated files (#14433)

This commit is contained in:
sfan5 2024-03-30 11:06:28 +01:00 committed by GitHub
parent bb6782ca58
commit 6c6e48f006
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 142 additions and 132 deletions

View file

@ -51,12 +51,13 @@ end
local function version_info_buttonhandler(this, fields)
if fields.version_check_remind then
-- Erase last known, user will be reminded again at next check
core.settings:set("update_last_known", "")
cache_settings:set("update_last_known", "")
this:delete()
return true
end
if fields.version_check_never then
core.settings:set("update_last_checked", "disabled")
-- clear checked URL
core.settings:set("update_information_url", "")
this:delete()
return true
end
@ -116,7 +117,7 @@ local function on_version_info_received(json)
return
end
local known_update = tonumber(core.settings:get("update_last_known")) or 0
local known_update = tonumber(cache_settings:get("update_last_known")) or 0
-- Format: MMNNPPP (Major, Minor, Patch)
local new_number = type(json.latest) == "table" and json.latest.version_code
@ -135,7 +136,7 @@ local function on_version_info_received(json)
return
end
core.settings:set("update_last_known", tostring(new_number))
cache_settings:set("update_last_known", tostring(new_number))
-- Show version info dialog (once)
maintab:hide()
@ -149,20 +150,20 @@ end
function check_new_version()
local url = core.settings:get("update_information_url")
if core.settings:get("update_last_checked") == "disabled" or
url == "" then
if url == "" then
-- Never show any updates
return
end
local time_now = os.time()
local time_checked = tonumber(core.settings:get("update_last_checked")) or 0
if time_now - time_checked < 2 * 24 * 3600 then
-- Check interval of 2 entire days
-- every 2 days
if check_cache_age("update_last_checked", 2 * 24 * 3600) then
return
end
cache_settings:set("update_last_checked", tostring(os.time()))
core.settings:set("update_last_checked", tostring(time_now))
-- Clean old leftovers (this can be removed after 5.9.0 or so)
core.settings:remove("update_last_checked")
core.settings:remove("update_last_known")
core.handle_async(function(params)
local http = core.get_http_api()