Misc: Get rid of the legacy defaults.lua globals (#9546)

* This removes support for the following deprecated constants: `DTAP_ZONE_FLIPPING`, `DTAP_ZONE_BOOKMARK`, `DCREREADER_CONFIG_DEFAULT_FONT_GAMMA`
* The "Advanced settings" panel now highlights modified values in bold (think about:config in Firefox ;)).
* LuaData: Isolate global table lookup shenanigans, and fix a few issues in unused-in-prod codepaths.
* CodeStyle: Require module locals for Lua/C modules, too.
* ScreenSaver: Actually garbage collect our widget on close (ScreenSaver itself is not an instantiated object).
* DateTimeWidget: Code cleanups to ensure child widgets can be GC'ed.
This commit is contained in:
NiLuJe
2022-09-28 01:10:50 +02:00
committed by GitHub
parent 46f729c248
commit 62059f8d68
74 changed files with 1030 additions and 1050 deletions

View File

@@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
-- Date at which the last migration snippet was added
local CURRENT_MIGRATION_DATE = 20220914
local CURRENT_MIGRATION_DATE = 20220922
-- Retrieve the date of the previous migration, if any
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
@@ -446,5 +446,34 @@ if last_migration_date < 20220914 then
end
end
-- The great defaults.persistent.lua migration to LuaDefaults
if last_migration_date < 20220922 then
logger.info("Performing one-time migration for 20220922")
local defaults_path = DataStorage:getDataDir() .. "/defaults.persistent.lua"
local defaults = {}
local load_defaults, err = loadfile(defaults_path, "t", defaults)
if not load_defaults then
logger.warn("loadfile:", err)
else
load_defaults()
end
for k, v in pairs(defaults) do
-- Don't migrate deprecated settings
if G_defaults:has(k) then
G_defaults:saveSetting(k, v)
end
end
G_defaults:flush()
local archived_path = DataStorage:getDataDir() .. "/defaults.legacy.lua"
local ok
ok, err = os.rename(defaults_path, archived_path)
if not ok then
logger.warn("os.rename:", err)
end
end
-- We're done, store the current migration date
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)