summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lbu-listbackups-html.lsp8
-rw-r--r--lbu-model.lua25
2 files changed, 22 insertions, 11 deletions
diff --git a/lbu-listbackups-html.lsp b/lbu-listbackups-html.lsp
index 2da5ab4..167e06e 100644
--- a/lbu-listbackups-html.lsp
+++ b/lbu-listbackups-html.lsp
@@ -33,11 +33,13 @@ html = require("acf.html")
<th>File</th>
</tr>
</thead><tbody>
- <% for i,name in ipairs(view.value) do %>
+ <% for i,file in ipairs(view.value) do %>
<tr><td>
- <% htmlviewfunctions.displayitem(cfe({type="link", value={backup=cfe({ type="hidden", value=name })}, label="", option="Revert", action="selectbackup"}), page_info, -1) %>
+ <% htmlviewfunctions.displayitem(cfe({type="link", value={backup=cfe({ type="hidden", value=file.filename })}, label="", option="Revert", action="selectbackup"}), page_info, -1) %>
</td>
- <td><%= html.html_escape(name) %></td></tr>
+ <td><%= html.html_escape(file.filename) %></td>
+ <td><span class="hide"><%= html.html_escape(file.size or 0) %>b</span><%= format.formatfilesize(file.size) %></td>
+ <td><%= format.formattime(file.mtime) %></td>
<% end %>
</tbody></table>
<% end %>
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