luci-base: dispatcher.lua: support "absent" fs dependency for menu nodes
authorJo-Philipp Wich <jo@mein.io>
Wed, 27 Apr 2022 11:13:12 +0000 (13:13 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 20 May 2022 18:23:26 +0000 (20:23 +0200)
The "absent" dependency type requires the given path to not exist on the
local system for the condition to be satisified. This is useful to disable
menu nodes depending on the presence of specific files.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 2e4b5fb8ff2fb3bfd1400bf7cbf721057f02fab9)

modules/luci-base/luasrc/dispatcher.lua

index e286430765be69df5739c7e2bc5e44e3bfc60eba..d27af0755afd6ea9e7760e048c2c5b66a6aebd27 100644 (file)
@@ -39,6 +39,10 @@ local function check_fs_depends(spec)
                        if fs.stat(path, "type") ~= "reg" then
                                return false
                        end
+               elseif kind == "absent" then
+                       if fs.stat(path, "type") then
+                               return false
+                       end
                end
        end