mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Added check to avoid copying non .lua files when plugin directories are created
This commit is contained in:
parent
d30c945ad7
commit
b1a17d990f
2 changed files with 28 additions and 15 deletions
|
|
@ -33,6 +33,7 @@ function file_utils.copy_file(fname, src_path, dst_path)
|
|||
if(ntop.exists(dst)) then
|
||||
-- NOTE: overwriting is not allowed as it means that a file was already provided by
|
||||
-- another plugin
|
||||
== io.write(debug.traceback())
|
||||
traceError(TRACE_ERROR, TRACE_CONSOLE, string.format("Trying to overwrite existing file %s", dst))
|
||||
return(false)
|
||||
end
|
||||
|
|
@ -61,14 +62,26 @@ end
|
|||
|
||||
-- #########################################################
|
||||
|
||||
function file_utils.recursive_copy(src_path, dst_path, path_map)
|
||||
function file_utils.recursive_copy(src_path, dst_path, path_map, required_extension)
|
||||
for fname in pairs(ntop.readdir(src_path)) do
|
||||
if not file_utils.copy_file(fname, src_path, dst_path) then
|
||||
return(false)
|
||||
local do_copy = true
|
||||
|
||||
if((required_extension ~= nil) and not(ends(fname, ".lua"))) then
|
||||
-- Don't copy
|
||||
do_copy = false
|
||||
traceError(TRACE_INFO, TRACE_CONSOLE, "SKIP file_utils.recursive_copy("..fname.." ["..src_path.." -> "..dst_path.."])\n")
|
||||
end
|
||||
|
||||
if path_map then
|
||||
path_map[os_utils.fixPath(dst_path .. "/" .. fname)] = os_utils.fixPath(src_path .. "/" .. fname)
|
||||
if(do_copy) then
|
||||
traceError(TRACE_INFO, TRACE_CONSOLE, "COPY file_utils.recursive_copy("..fname.." ["..src_path.." -> "..dst_path.."])\n")
|
||||
|
||||
if not file_utils.copy_file(fname, src_path, dst_path) then
|
||||
return(false)
|
||||
end
|
||||
|
||||
if path_map then
|
||||
path_map[os_utils.fixPath(dst_path .. "/" .. fname)] = os_utils.fixPath(src_path .. "/" .. fname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue