mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Reduces the number of files open by housekeeping.lua
This commit is contained in:
parent
46439a8c02
commit
3509b783f5
7 changed files with 67 additions and 50 deletions
|
|
@ -3521,48 +3521,6 @@ function path_get_page(path)
|
|||
return path
|
||||
end
|
||||
|
||||
-- ###########################################
|
||||
|
||||
function savePrefsToDisk()
|
||||
local dirs = ntop.getDirs()
|
||||
local where = os_utils.fixPath(dirs.workingdir.."/runtimeprefs.json")
|
||||
local keys = ntop.getKeysCache("ntopng.prefs.*")
|
||||
|
||||
local out = {}
|
||||
for k in pairs(keys or {}) do
|
||||
out[k] = ntop.dumpCache(k)
|
||||
end
|
||||
|
||||
local json = require("dkjson")
|
||||
local dump = json.encode(out, nil, 1)
|
||||
|
||||
local file = io.open(where, "w")
|
||||
file:write(dump)
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- ###########################################
|
||||
|
||||
function readPrefsFromDisk()
|
||||
local dirs = ntop.getDirs()
|
||||
local where = os_utils.fixPath(dirs.workingdir.."/runtimeprefs.json")
|
||||
local file = io.open(where, "r")
|
||||
|
||||
if(file ~= nil) then
|
||||
local dump = file:read()
|
||||
file:close()
|
||||
|
||||
local json = require("dkjson")
|
||||
local restore = json.decode(dump, 1, nil)
|
||||
|
||||
for k,v in pairs(restore or {}) do
|
||||
-- print(k.."\n")
|
||||
ntop.delCache(k)
|
||||
ntop.restoreCache(k,v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ###########################################
|
||||
--
|
||||
-- IMPORTANT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue