summaryrefslogtreecommitdiffstats
path: root/lbu-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lbu-model.lua')
-rw-r--r--lbu-model.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index ac9f926..e06add2 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -156,6 +156,17 @@ local function validatefilecontent (filedetails)
return success, filedetails
end
+local listbackupfiles = function()
+ local files = {}
+ local content = modelfunctions.run_executable({"lbu", "lb"})
+ if not string.match(content, "usage: lbu") then
+ for line in string.gmatch(content, "([^\n]+)\n?") do
+ files[#files + 1] = line
+ end
+ end
+ return files
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -365,20 +376,18 @@ end
function mymodule.getbackupfiles()
local files = {}
- local content = modelfunctions.run_executable({"lbu", "lb"})
- if not string.match(content, "usage: lbu") then
- for line in string.gmatch(content, "([^\n]+)\n?") do
- files[#files + 1] = line
- end
+ for i,file in ipairs(listbackupfiles()) do
+ local filedetails = posix.stat(file)
+ filedetails.filename = file
+ file[#files+1] = filedetails
end
- return cfe({ type="list", value=files, label="Backup Archives"})
+ return cfe({ type="structure", value=files, label="Backup Archives"})
end
function mymodule.get_selectbackup(self, clientdata)
local result = {}
result.backup = cfe({ type="select", value=clientdata.backup or "", label="Backup" })
- local files = mymodule.getbackupfiles()
- result.backup.option = files.value
+ result.backup.option = listbackupfiles()
return cfe({ type="group", value=result, label="Revert to Backup" })
end