From 4d3d351fface621896b510df7acc33e8ff3c60dc Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 11 May 2015 10:05:26 -0400 Subject: Revert "Fix exception in logfile-model due to change to luaposix API" This reverts commit d93ee8df55aa6b41b043614cfae5c3805dac11c9. --- logfiles-model.lua | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/logfiles-model.lua b/logfiles-model.lua index 9fa36e7..590b3ae 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -1,8 +1,7 @@ -- acf model for displaying logfiles local mymodule = {} -dirent = require("posix.dirent") -unistd = require("posix.unistd") +posix = require("posix") modelfunctions = require("modelfunctions") fs = require("acf.fs") format = require("acf.format") @@ -12,12 +11,7 @@ local function file_info ( path ) -- Check if file is in use local st = fs.stat(path) while st.type == "link" do - local ok,link = pcall(unistd.readlink, st.path) - if ok and link then - st = fs.stat(link) - else - break - end + st = fs.stat(posix.readlink(st.path)) end local size = st.size or "0" local lastmod = st.mtime or "---" @@ -30,23 +24,14 @@ end local function recursedir(path, filearray) filearray = filearray or {} local k,v - local ok, files = pcall(dirent.dir, path) - if not ok then - return {} - end - for k,v in pairs(files) do + for k,v in pairs(posix.dir(path) or {}) do -- Ignore files that begins with a '.' if not string.match(v, "^%.") then local f = path .. "/" .. v -- If subfolder exists, list files in this subfolder local st = fs.stat(f) while st and st.type == "link" do - local ok,link = pcall(unistd.readlink, st.path) - if ok and link then - st = fs.stat(link) - else - break - end + st = fs.stat(posix.readlink(st.path)) end if st and st.type == "directory" then recursedir(f, filearray) @@ -108,12 +93,7 @@ mymodule.get_filedetails = function (path, grep) if success then local st = fs.stat(path) while st.type == "link" do - local ok,link = pcall(unistd.readlink, st.path) - if ok and link then - st = fs.stat(link) - else - break - end + st = fs.stat(posix.readlink(st.path)) end file = st.path end @@ -190,12 +170,7 @@ mymodule.delete = function (self, filetodelete) else local st = fs.stat(filetodelete.value.filename.value) while st.type == "link" do - local ok,link = pcall(unistd.readlink, st.path) - if ok and link then - st = fs.stat(link) - else - break - end + st = fs.stat(posix.readlink(st.path)) end local status, err = os.remove( st.path ) if err then -- cgit v1.2.3