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>
Wed, 27 Apr 2022 11:19:23 +0000 (13:19 +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>
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