gluon-autoupdater: factor out default_branch() function
Make the code clearer and prepare for invalid branch fixup.
This commit is contained in:
parent
db48b6b693
commit
2c65f0834b
@ -21,16 +21,21 @@ for name, config in pairs(site.autoupdater.branches()) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function default_branch()
|
||||||
|
local f = io.open('/lib/gluon/autoupdater/default_branch')
|
||||||
|
if f then
|
||||||
|
local ret = f:read('*line')
|
||||||
|
f:close()
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
return site.autoupdater.branch(min_branch)
|
||||||
|
end
|
||||||
|
|
||||||
if not uci:get('autoupdater', 'settings') then
|
if not uci:get('autoupdater', 'settings') then
|
||||||
local enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil
|
local enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil
|
||||||
|
|
||||||
local branch = site.autoupdater.branch(min_branch)
|
local branch = default_branch()
|
||||||
local f = io.open('/lib/gluon/autoupdater/default_branch')
|
|
||||||
if f then
|
|
||||||
branch = f:read('*line')
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
if not branch then
|
if not branch then
|
||||||
enabled = false
|
enabled = false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user