diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-12-30 19:29:47 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-12-30 19:29:47 +0000 |
commit | 58dcae2ff22fc58b75296518a8f6da174375ada9 (patch) | |
tree | dd3e6459036f3dfd3912ec0fd7503d1473bacf2e /logfiles-model.lua | |
parent | 4f44e5c5e066f9ac287151e5b1f0fa515367d613 (diff) | |
download | acf-alpine-baselayout-58dcae2ff22fc58b75296518a8f6da174375ada9.tar.bz2 acf-alpine-baselayout-58dcae2ff22fc58b75296518a8f6da174375ada9.tar.xz |
Change logfiles.status to return a structure rather than a list of cfe's for each file
This makes it like listfiles actions in other ACFs. Tested and still works with acf-weblog.
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r-- | logfiles-model.lua | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua index df35f0c..b5b08cf 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -137,20 +137,15 @@ mymodule.tail = function(self, clientdata) end mymodule.get = function () - -- Loop through each file and present its info - local listed_files = {} + local retval = {} for i,file in pairs(list_files()) do - -- Get info on this specific file and put it in a table - local st = posix.stat(file) - local filename = cfe({ value=file, label="File name" }) - local size = cfe({ value=st.size, label="File size" }) - local mtime = cfe({ value=st.mtime, label="File date" }) - local inuse = cfe({ type="boolean", value=is_file_in_use(file), label="File in use" }) - table.insert ( listed_files , cfe({ type="group", value={filename=filename, size=size, mtime=mtime, - inuse=inuse, label="File details"} }) ) + local details = posix.stat(file) + details.filename = file + details.inuse = is_file_in_use(file) + table.insert(retval, details) end - table.sort(listed_files, function (a,b) return (a.value.filename.value < b.value.filename.value) end ) - return cfe({ type="list", value=listed_files, label="Log Files" }) + table.sort(retval, function(a,b) return a.filename < b.filename end) + return cfe({ type="structure", value=retval, label="Log Files" }) end mymodule.get_delete = function() |