diff options
author | Mika Havela <mika.havela@gmail.com> | 2009-07-02 15:21:39 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2009-07-02 15:21:39 +0000 |
commit | b107185f3794c982ec0c988087232346e67a8203 (patch) | |
tree | dcae6bc40b003dcd5e9ad9a5b98168ab600ee8fb /rrdtool-model.lua | |
parent | bc9c06910c0544c3f3029db287beda85afa2b542 (diff) | |
download | acf-rrdtool-b107185f3794c982ec0c988087232346e67a8203.tar.bz2 acf-rrdtool-b107185f3794c982ec0c988087232346e67a8203.tar.xz |
Adding delete() to be able to remove .rrd DB's
Hiding some debug information in the listrrd view-file.
Diffstat (limited to 'rrdtool-model.lua')
-rw-r--r-- | rrdtool-model.lua | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/rrdtool-model.lua b/rrdtool-model.lua index 9e9295f..f85f08b 100644 --- a/rrdtool-model.lua +++ b/rrdtool-model.lua @@ -43,13 +43,13 @@ local function file_info ( path ) return lastmod,size end -local function list_files ( ... ) +local function list_files () local listed_files = {} local open_files = {} local files = {} local k,v -- Generate a single table with all the files - for k,v in pairs{...} do + for k,v in pairs{databases} do recursedir(v, files) end @@ -68,6 +68,15 @@ local function list_files ( ... ) end +local function validfilename(path) + local files = list_files() + for k,v in pairs(files.value) do + if (v["value"]["filename"]["value"] == path) then + return true, tostring(v["value"]["filename"]["value"]) + end + end + return false, "Not a valid filename!" +end -- ################################################################################ -- PUBLIC FUNCTIONS @@ -89,7 +98,7 @@ function setconfigfile(filedetails) end function getrrdlist() - return list_files(databases) + return list_files() end function createnewrrd() @@ -102,3 +111,17 @@ DS:ds-name:COMPUTE:rpn-expression"}) newdb.rra = cfe({label="Round Robin Archive",value="",descr="RRA:AVERAGE | MIN | MAX | LAST:xff:steps:rows"}) return {value=newdb} end + +function remove_file(self, path, userid) + local success = "Failed to delete file" + local errtxt + if not (fs.is_file(path)) then + errtxt = "File doesn't exist!" + elseif (validfilename(path)) then + os.remove(path) + success = "File Deleted" + else + errtxt = "Not a valid filename!" + end + return cfe({ value=success, label="Delete config file result", errtxt=errtxt }) +end |