From a5f0492a13ed1f322a582478c7155f964c41deba Mon Sep 17 00:00:00 2001 From: Wouter R Date: Mon, 24 Feb 2014 20:15:00 +0100 Subject: [PATCH] Identify beta->stable transition as 'update' when includeBetas setting is false. Fix in index generator in update publisher. --- extra/scripts/publish-wifibox-release.lua | 2 +- src/rest/api/api_update.lua | 1 + src/script/d3d-updater.lua | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/extra/scripts/publish-wifibox-release.lua b/extra/scripts/publish-wifibox-release.lua index ca36ebc..5bb9ca0 100755 --- a/extra/scripts/publish-wifibox-release.lua +++ b/extra/scripts/publish-wifibox-release.lua @@ -298,7 +298,7 @@ local function generateIndex(newVersion, versionTable, isStable) idxFile:write("Files: " .. el.sysupgradeFilename .. "; " .. el.factoryFilename .. "\n") idxFile:write("FileSize: " .. el.sysupgradeFileSize .. "; " .. el.factoryFileSize .. "\n") idxFile:write("MD5: " .. el.sysupgradeMD5 .. "; " .. el.factoryMD5 .. "\n") - idxFile:write("ReleaseDate: " .. um.formatDate(el.timestamp) .. "\n") + if el.timestamp then idxFile:write("ReleaseDate: " .. um.formatDate(el.timestamp) .. "\n") end end) idxFile:close() diff --git a/src/rest/api/api_update.lua b/src/rest/api/api_update.lua index 827f85f..a7e48c7 100644 --- a/src/rest/api/api_update.lua +++ b/src/rest/api/api_update.lua @@ -63,6 +63,7 @@ function M.status(request, response) end local canUpdate = updater.compareVersions(status.newestVersion, status.currentVersion, status.newestReleaseTimestamp, status.currentReleaseTimestamp) > 0 + if (status.currentVersion.suffix ~= nil) and not includeBetas then canUpdate = true end -- always allow downgrade from beta to stable if !includeBetas response:addData('newest_version', updater.formatVersion(status.newestVersion)) if status.currentReleaseTimestamp then response:addData('current_release_date', updater.formatDate(status.currentReleaseTimestamp)) end diff --git a/src/script/d3d-updater.lua b/src/script/d3d-updater.lua index f6809ac..6535985 100644 --- a/src/script/d3d-updater.lua +++ b/src/script/d3d-updater.lua @@ -439,16 +439,28 @@ function M.getStatus(withBetas) local verTable,msg = M.getAvailableVersions(withBetas and 'both' or 'stables') if not verTable then D("error: could not obtain available versions (" .. msg .. ")") - -- TODO: set an error state in result to signify we probably do not have internet access? return false, result, msg end + -- NOTE: to look up the current version we need a table containing all versions + local allVersionsTable,msg + if not withBetas then + allVersionsTable,msg = M.getAvailableVersions('both') + if not allVersionsTable then + D("error: could not obtain available versions including betas (" .. msg .. ")") + return false, result, msg + end + else + allVersionsTable = verTable + end + + local newest = verTable and verTable[#verTable] 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, nil, verTable) + local cEnt = M.findVersion(result.currentVersion, nil, allVersionsTable) if cEnt then result.currentReleaseTimestamp = cEnt.timestamp else @@ -531,7 +543,6 @@ function M.versionsEqual(versionA, versionB, timestampA, timestampB) end --- Returns information on a version if it can be found in a collection of versions as returned by @{getAvailableVersions}. --- FIXME: if no version table is passed in, it will be downloaded but betas will never be included -- @tparam table version The version to look for. -- @tparam bool[opt] withBetas If verTable is not given, download versions including beta releases -- @tparam table[opt] verTable A table containing a collection of versions, if not passed in, it will be obtained using @{getAvailableVersions}. @@ -541,7 +552,7 @@ end function M.findVersion(version, withBetas, verTable, timestamp) local msg = nil version = M.parseVersion(version) - if not verTable then verTable,msg = M.getAvailableVersions(withBetas and 'both' or nil) end + if not verTable then verTable,msg = M.getAvailableVersions(withBetas and 'both' or 'stables') end if not verTable then return nil,msg end