summaryrefslogtreecommitdiffstats
path: root/lbu-controller.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-23 14:31:44 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-23 14:31:44 +0000
commitb6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23 (patch)
tree8d38ec02518e736922c41961545d8123191641b0 /lbu-controller.lua
parent8d5450a1ad2402c0e5b764a5e033cd9134dd4d23 (diff)
downloadacf-alpine-conf-b6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23.tar.bz2
acf-alpine-conf-b6c2c25e5e99b6d8515a777a00f5a97c1f6b1d23.tar.xz
Forcing user to enter valid options in the config-tab before making a commit.
Displaying current errors in the config/settings. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-conf/trunk@628 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lbu-controller.lua')
-rw-r--r--lbu-controller.lua33
1 files changed, 26 insertions, 7 deletions
diff --git a/lbu-controller.lua b/lbu-controller.lua
index c13bc5c..d8703e9 100644
--- a/lbu-controller.lua
+++ b/lbu-controller.lua
@@ -19,12 +19,15 @@ end
status = function (self)
local cmd = self.clientdata.cmd
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
- return ( {status = self.model:getstatus(),
+ local status, errors = self.model:getstatus()
+ return ( {status = status,
+ errors = errors,
lbustatus = self.model:list(),
url = url, } )
end
config = function (self)
+ local errors = {}
local cmdresult
if (self.clientdata.cmd_delete_excluded) and (self.clientdata.lbu_excluded) then
cmdresult = self.model:lbuincexcl("exclude", self.clientdata.lbu_excluded, "remove")
@@ -50,30 +53,46 @@ config = function (self)
cmdresult = self.model:lbuincexcl("exclude", self.clientdata.item_add_exclude, "add")
end
-
+ -- This needs to be done /after/ the editing of the config (done earlier in this code)
+ local status,errors = self.model:getstatus()
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
- return ( {status = self.model:getstatus(),
+ return ( {status = status,
cmdresult = cmdresult,
+ errors = errors,
clientdata = self.clientdata,
config = self.model:getconfig(),
url = url, } )
end
function commit(self)
- local cmdresult
+ local cmdresult, cmderror
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
local cmdflag = nil
if (self.clientdata.lbucleanmedia) then cmdflag = "-d" else cmdflag = "" end
if (self.clientdata.lbusimulate) then
- cmdresult = self.model:getsimulate(cmdflag)
+ cmdresult, cmderror = self.model:getsimulate(cmdflag)
end
if (self.clientdata.lbucommit) then
- cmdresult = self.model:getcommit(cmdflag)
+ cmdresult, cmderror = self.model:getcommit(cmdflag)
+ end
+
+ -- If no clientdata then do a dryrun and see if it's going to work else report
+ if not (cmdresult) then
+ tmp_cmdresult, cmderror = self.model:getsimulate()
+ end
+
+ local status, errors = self.model:getstatus()
+ if (errors.last) then
+ self.conf.action = "config"
+ self.conf.type = "redir"
+ return config(self)
end
- return ( {status = self.model:getstatus(),
+ return ( {status = status,
+ errors = errors,
cmdresult = cmdresult,
cmdflag = cmdflag,
+ cmderror = cmderror,
clientdata = self.clientdata,
url = url, } )
end