Disable external plugins and user-patches (#15593)
This commit is contained in:
1 parent
5549f8ac6c
commit
f5579dd5fa
7 files changed
+51
-7
No files matched your search
+21
-3
@@ -35,8 +35,26 @@ local DataStorage = require("datastorage")
|
||||
|
||||
-- the directory KOReader is installed in (and runs from)
|
||||
local package_dir = lfs.currentdir()
|
||||
-- the directory where KOReader stores user data
|
||||
local data_dir = DataStorage:getDataDir()
|
||||
local patch_dir = DataStorage:getPatchesDir()
|
||||
local patches_disabled_path = patch_dir .. "/.patches_disabled"
|
||||
local patches_disabled = lfs.attributes(patches_disabled_path, "mode") == "file"
|
||||
|
||||
function userpatch.arePatchesDisabled()
|
||||
return patches_disabled
|
||||
end
|
||||
|
||||
function userpatch.togglePatchesDisabled()
|
||||
if patches_disabled then
|
||||
os.remove(patches_disabled_path)
|
||||
patches_disabled = false
|
||||
else
|
||||
local file = io.open(patches_disabled_path, "w")
|
||||
if file then
|
||||
file:close()
|
||||
patches_disabled = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Run lua patches
|
||||
-- Execution order order is alphanum-sort for humans version 4: `1-patch.lua` is executed before `10-patch.lua`
|
||||
@@ -90,7 +108,7 @@ end
|
||||
--- This function applies lua patches from `/koreader/patches`
|
||||
---- @string priority ... one of the defined priorities in the userpatch hashtable
|
||||
function userpatch.applyPatches(priority)
|
||||
local patch_dir = data_dir .. "/patches"
|
||||
if patches_disabled then return end
|
||||
local update_once_marker = package_dir .. "/update_once.marker"
|
||||
local update_once_pending = lfs.attributes(update_once_marker, "mode") == "file"
|
||||
|
||||
|
||||
Reference in new issue
Block a user