summaryrefslogtreecommitdiffstats
path: root/lbu-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lbu-model.lua')
-rw-r--r--lbu-model.lua21
1 files changed, 7 insertions, 14 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index 69eacfc..c190c34 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -153,8 +153,9 @@ local function validatefilelist(filelist)
return filelist
end
-local function validatefilecontent (filecontent)
- local config = getconfig(filecontent.value)
+local function validatefilecontent (filedetails)
+ local success = true
+ local config = getconfig(filedetails.value.filecontent.value)
local errors = {}
for name,value in pairs(config.value) do
if value.errtxt then
@@ -162,10 +163,11 @@ local function validatefilecontent (filecontent)
end
end
if #errors > 0 then
- filecontent.errtxt = table.concat(errors, "\n")
+ success = false
+ filedetails.value.filecontent.errtxt = table.concat(errors, "\n")
end
- return filecontent
+ return success, filedetails
end
--[[
local was_mounted
@@ -348,16 +350,7 @@ function get_filedetails()
end
function set_filedetails(filedetails)
- local filecontent = filedetails.value.filecontent
- filecontent.value = format.dostounix(filecontent.value)
- filecontent.value = filecontent.value:gsub("\n+$", "")
- validatefilecontent(filecontent)
- if not filecontent.errtxt then
- fs.write_file(configfile, filecontent.value)
- else
- filedetails.errtxt = "Failed to set config"
- end
- return filedetails
+ return modelfunctions.setfiledetails(filedetails, {configfile}, validatefilecontent)
end
function getcommit()