summaryrefslogtreecommitdiffstats
path: root/logfiles-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r--logfiles-model.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua
index 6ef6a1d..2ac4f5d 100644
--- a/logfiles-model.lua
+++ b/logfiles-model.lua
@@ -1,13 +1,14 @@
-- acf model for displaying logfiles
module (..., package.seeall)
require("fs")
+require("modelfunctions")
-- Function to get detailed information on a specific file.
local function file_info ( path )
-- Check if file is in use
local st = fs.stat(path)
- local size = st.size
- local lastmod = st.mtime
+ local size = st.size or "0"
+ local lastmod = st.mtime or "---"
local file_inuse = io.popen("fuser " .. path )
local fileinuseresult = file_inuse:read("*a") or "unknown"
file_inuse:close()
@@ -64,11 +65,14 @@ get_filedetails = function (path)
local available_files = get()
for i,file in ipairs(available_files.value) do
if ( file.value.filename.value == path ) then
- filedetails = file
- filedetails.value.filecontent = cfe({ type="longtext", value=fs.read_file(path), label="File content" })
+ filedetails = modelfunctions.getfiledetails(path)
break
end
end
+ if not filedetails then
+ filedetails = modelfunctions.getfiledetails("")
+ filedetails.value.filename.value = path
+ end
return filedetails
end