mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 02:53:49 +01:00
Extend updater and API to support betas and release dates (untested).
This commit is contained in:
parent
b6862c17cc
commit
8582f88e06
@ -335,4 +335,10 @@ M.doodle3d_tour_enabled = {
|
|||||||
description = 'Show tour to new users'
|
description = 'Show tour to new users'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M.doodle3d_betas = {
|
||||||
|
default = false,
|
||||||
|
type = 'bool',
|
||||||
|
description = 'Update to beta releases',
|
||||||
|
}
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -49,9 +49,9 @@ end
|
|||||||
function M.status(request, response)
|
function M.status(request, response)
|
||||||
updater.setLogger(log)
|
updater.setLogger(log)
|
||||||
updater.setUseCache(false)
|
updater.setUseCache(false)
|
||||||
local success,status,msg = updater.getStatus()
|
local includeBetas = settings.get('doodle3d.betas')
|
||||||
|
local success,status,msg = updater.getStatus(includeBetas)
|
||||||
|
|
||||||
--response:addData('current_version', status.currentVersion)
|
|
||||||
response:addData('current_version', updater.formatVersion(status.currentVersion))
|
response:addData('current_version', updater.formatVersion(status.currentVersion))
|
||||||
|
|
||||||
response:addData('state_code', status.stateCode)
|
response:addData('state_code', status.stateCode)
|
||||||
@ -62,10 +62,11 @@ function M.status(request, response)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local canUpdate = updater.compareVersions(status.newestVersion, status.currentVersion) > 0
|
local canUpdate = updater.compareVersions(status.newestVersion, status.currentVersion, status.newestReleaseTimestamp, status.currentReleaseTimestamp) > 0
|
||||||
|
|
||||||
--response:addData('newest_version', status.newestVersion)
|
|
||||||
response:addData('newest_version', updater.formatVersion(status.newestVersion))
|
response:addData('newest_version', updater.formatVersion(status.newestVersion))
|
||||||
|
if status.currentReleaseTimestamp then response:addData('current_release_date', updater.formatDate(status.currentReleaseTimestamp)) end
|
||||||
|
if status.newestReleaseTimestamp then response:addData('newest_release_date', updater.formatDate(status.newestReleaseTimestamp)) end
|
||||||
response:addData('can_update', canUpdate)
|
response:addData('can_update', canUpdate)
|
||||||
|
|
||||||
if status.progress then response:addData('progress', status.progress) end
|
if status.progress then response:addData('progress', status.progress) end
|
||||||
@ -94,7 +95,8 @@ function M.download_POST(request, response)
|
|||||||
local vEnt, rv, msg
|
local vEnt, rv, msg
|
||||||
|
|
||||||
if not argVersion then
|
if not argVersion then
|
||||||
local success,status,msg = updater.getStatus()
|
local includeBetas = settings.get('doodle3d.betas')
|
||||||
|
local success,status,msg = updater.getStatus(includeBetas)
|
||||||
if not success then
|
if not success then
|
||||||
updater.setState(updater.STATE.DOWNLOAD_FAILED, msg)
|
updater.setState(updater.STATE.DOWNLOAD_FAILED, msg)
|
||||||
response:setFail(msg)
|
response:setFail(msg)
|
||||||
@ -153,9 +155,9 @@ function M.install_POST(request, response)
|
|||||||
local argNoRetain = request:get("no_retain")
|
local argNoRetain = request:get("no_retain")
|
||||||
log:info("API:update/install (noRetain: "..utils.dump(argNoRetain)..")")
|
log:info("API:update/install (noRetain: "..utils.dump(argNoRetain)..")")
|
||||||
local noRetain = argNoRetain == 'true'
|
local noRetain = argNoRetain == 'true'
|
||||||
|
|
||||||
if not operationsAccessOrFail(request, response) then return end
|
if not operationsAccessOrFail(request, response) then return end
|
||||||
|
|
||||||
updater.setLogger(log)
|
updater.setLogger(log)
|
||||||
updater.setState(updater.STATE.INSTALLING,"")
|
updater.setState(updater.STATE.INSTALLING,"")
|
||||||
|
|
||||||
@ -163,7 +165,8 @@ function M.install_POST(request, response)
|
|||||||
--local rv,msg = netconf.enableAccessPoint(ssid)
|
--local rv,msg = netconf.enableAccessPoint(ssid)
|
||||||
|
|
||||||
if not argVersion then
|
if not argVersion then
|
||||||
local success,status,msg = updater.getStatus()
|
local includeBetas = settings.get('doodle3d.betas')
|
||||||
|
local success,status,msg = updater.getStatus(includeBetas)
|
||||||
if not success then
|
if not success then
|
||||||
updater.setState(updater.STATE.INSTALL_FAILED, msg)
|
updater.setState(updater.STATE.INSTALL_FAILED, msg)
|
||||||
response:setFail(msg)
|
response:setFail(msg)
|
||||||
|
@ -396,7 +396,7 @@ end
|
|||||||
-- @treturn bool True if status has been determined fully, false if not.
|
-- @treturn bool True if status has been determined fully, false if not.
|
||||||
-- @treturn table The result table.
|
-- @treturn table The result table.
|
||||||
-- @treturn ?string Descriptive message in case the result table is not complete.
|
-- @treturn ?string Descriptive message in case the result table is not complete.
|
||||||
function M.getStatus()
|
function M.getStatus(includeBetas)
|
||||||
if not baseUrl then baseUrl = M.DEFAULT_BASE_URL end
|
if not baseUrl then baseUrl = M.DEFAULT_BASE_URL end
|
||||||
local unknownVersion = { major = 0, minor = 0, patch = 0 }
|
local unknownVersion = { major = 0, minor = 0, patch = 0 }
|
||||||
local result = {}
|
local result = {}
|
||||||
@ -405,15 +405,24 @@ function M.getStatus()
|
|||||||
result.stateCode, result.stateText = getState()
|
result.stateCode, result.stateText = getState()
|
||||||
result.stateCode = tonumber(result.stateCode)
|
result.stateCode = tonumber(result.stateCode)
|
||||||
|
|
||||||
local verTable,msg = M.getAvailableVersions()
|
local verTable,msg = M.getAvailableVersions(includeBetas and 'both' or 'stables')
|
||||||
if not verTable then
|
if not verTable then
|
||||||
D("could not obtain available versions (" .. msg .. ")")
|
D("error: could not obtain available versions (" .. msg .. ")")
|
||||||
-- TODO: set an error state in result to signify we probably do not have internet access?
|
-- TODO: set an error state in result to signify we probably do not have internet access?
|
||||||
return false, result, msg
|
return false, result, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
local newest = verTable and verTable[#verTable]
|
local newest = verTable and verTable[#verTable]
|
||||||
result.newestVersion = newest and newest.version or unknownVersion
|
result.newestVersion = newest and newest.version or unknownVersion
|
||||||
|
result.newestReleaseTimestamp = newest and newest.timestamp
|
||||||
|
|
||||||
|
-- look up timestamp of current version
|
||||||
|
local cEnt = M.findVersion(result.currentVersion, verTable)
|
||||||
|
if cEnt then
|
||||||
|
result.currentReleaseTimestamp = cEnt.timestamp
|
||||||
|
else
|
||||||
|
D("warning: could not find current wifibox version in release index, beta setting disabled after having beta installed?")
|
||||||
|
end
|
||||||
|
|
||||||
if result.stateCode == M.STATE.DOWNLOADING then
|
if result.stateCode == M.STATE.DOWNLOADING then
|
||||||
result.progress = fileSize(cachePath .. '/' .. newest.sysupgradeFilename)
|
result.progress = fileSize(cachePath .. '/' .. newest.sysupgradeFilename)
|
||||||
|
Loading…
Reference in New Issue
Block a user