Add checks to avoid startup failures when plugins metadata does not exist

This commit is contained in:
emanuele-f 2020-04-27 12:25:48 +02:00
parent 80da76314d
commit 7191f3e1a5

View file

@ -734,7 +734,11 @@ end
local function load_metadata()
if(METADATA == nil) then
METADATA = dofile(getMetadataPath())
local path = getMetadataPath()
if ntop.exists(path) then
METADATA = dofile(path)
end
end
end
@ -746,6 +750,10 @@ end
function plugins_utils.getUserScriptSourcePath(script_path)
load_metadata()
if(not METADATA) then
return(nil)
end
local info = METADATA.path_map[script_path]
if info then
@ -779,6 +787,10 @@ end
function plugins_utils.getUserScriptPlugin(script_path)
load_metadata()
if(not METADATA) then
return(nil)
end
local info = METADATA.path_map[script_path]
if info then
@ -793,6 +805,10 @@ end
function plugins_utils.getLoadedPlugins()
load_metadata()
if(not METADATA) then
return({})
end
return(METADATA.plugins)
end