|
|
@ -87,7 +87,7 @@ dbot.version : Module to track version and changelog information and update the
|
|
|
|
save_state="y"
|
|
|
|
save_state="y"
|
|
|
|
date_written="2017-08-12 08:45:15"
|
|
|
|
date_written="2017-08-12 08:45:15"
|
|
|
|
requires="4.98"
|
|
|
|
requires="4.98"
|
|
|
|
version="2.0005"
|
|
|
|
version="2.0006"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<description trim="y">
|
|
|
|
<description trim="y">
|
|
|
|
<![CDATA[
|
|
|
|
<![CDATA[
|
|
|
@ -4410,13 +4410,13 @@ function inv.cli.version.fn(name, line, wildcards)
|
|
|
|
|
|
|
|
|
|
|
|
elseif (command == "changelog") then
|
|
|
|
elseif (command == "changelog") then
|
|
|
|
dbot.info("Full changelog:")
|
|
|
|
dbot.info("Full changelog:")
|
|
|
|
retval = dbot.version.changelog(0, line) -- show changelog from version 0 to the latest
|
|
|
|
retval = dbot.version.changelog.get(0, line) -- show changelog from version 0 to the latest
|
|
|
|
|
|
|
|
|
|
|
|
elseif (command == "check") then
|
|
|
|
elseif (command == "check") then
|
|
|
|
retval = dbot.update.version(drlDbotUpdateCheck, line)
|
|
|
|
retval = dbot.version.update.release(drlDbotUpdateCheck, line)
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
retval = dbot.update.version(drlDbotUpdateInstall, line)
|
|
|
|
retval = dbot.version.update.release(drlDbotUpdateInstall, line)
|
|
|
|
|
|
|
|
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
@ -19562,54 +19562,64 @@ end -- dbot.remote.getCR
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
-- dbot.version: Track the plugin's version and changelog and update the plugin
|
|
|
|
-- dbot.version: Track the plugin's version and changelog and update the plugin
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- dbot.version.changelog(minVersion, endTag)
|
|
|
|
-- dbot.version.changelog.get(minVersion, endTag)
|
|
|
|
-- dbot.version.changelogCR()
|
|
|
|
-- dbot.version.changelog.getCR()
|
|
|
|
-- dbot.version.displayChanges(minVersion, changeLog)
|
|
|
|
-- dbot.version.changelog.displayChanges(minVersion, changeLog)
|
|
|
|
-- dbot.version.displayChange(changeLogEntries)
|
|
|
|
-- dbot.version.changelog.displayChange(changeLogEntries)
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- dbot.version.update.release(mode, endTag)
|
|
|
|
-- Note: This code is derived from a plugin written by Arcidayne. Thanks Arcidayne!
|
|
|
|
-- dbot.version.update.releaseCR()
|
|
|
|
|
|
|
|
-- Note: dbot.version.update is derived from a plugin written by Arcidayne. Thanks Arcidayne!
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
dbot.version = {}
|
|
|
|
dbot.version = {}
|
|
|
|
dbot.version.changeLogPkg = nil
|
|
|
|
|
|
|
|
|
|
|
|
dbot.version.changelog = {}
|
|
|
|
|
|
|
|
dbot.version.changelog.pkg = nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbot.version.update = {}
|
|
|
|
|
|
|
|
dbot.version.update.pkg = nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drlDbotUpdateCheck = "check"
|
|
|
|
|
|
|
|
drlDbotUpdateInstall = "install"
|
|
|
|
|
|
|
|
|
|
|
|
drlDbotChangeLogTypeFix = "@RFix@W"
|
|
|
|
drlDbotChangeLogTypeFix = "@RFix@W"
|
|
|
|
drlDbotChangeLogTypeNew = "@GNew@W"
|
|
|
|
drlDbotChangeLogTypeNew = "@GNew@W"
|
|
|
|
drlDbotChangeLogTypeMisc = "@yMsc@W"
|
|
|
|
drlDbotChangeLogTypeMisc = "@yMsc@W"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dbot.version.changelog(minVersion, endTag)
|
|
|
|
function dbot.version.changelog.get(minVersion, endTag)
|
|
|
|
local url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.changelog"
|
|
|
|
local url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.changelog"
|
|
|
|
local protocol = "HTTPS"
|
|
|
|
local protocol = "HTTPS"
|
|
|
|
|
|
|
|
|
|
|
|
if (dbot.version.changeLogPkg ~= nil) then
|
|
|
|
if (dbot.version.changelog.pkg ~= nil) then
|
|
|
|
dbot.info("Skipping changelog request: another request is in progress")
|
|
|
|
dbot.info("Skipping changelog request: another request is in progress")
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_BUSY)
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_BUSY)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
dbot.version.changeLogPkg = {}
|
|
|
|
dbot.version.changelog.pkg = {}
|
|
|
|
dbot.version.changeLogPkg.url = url
|
|
|
|
dbot.version.changelog.pkg.url = url
|
|
|
|
dbot.version.changeLogPkg.protocol = protocol
|
|
|
|
dbot.version.changelog.pkg.protocol = protocol
|
|
|
|
dbot.version.changeLogPkg.minVersion = minVersion or 0
|
|
|
|
dbot.version.changelog.pkg.minVersion = minVersion or 0
|
|
|
|
dbot.version.changeLogPkg.endTag = endTag
|
|
|
|
dbot.version.changelog.pkg.endTag = endTag
|
|
|
|
|
|
|
|
|
|
|
|
wait.make(dbot.version.changelogCR)
|
|
|
|
wait.make(dbot.version.changelog.getCR)
|
|
|
|
|
|
|
|
|
|
|
|
return DRL_RET_SUCCESS
|
|
|
|
return DRL_RET_SUCCESS
|
|
|
|
end -- dbot.version.changelog
|
|
|
|
end -- dbot.version.changelog.get
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dbot.version.changelogCR()
|
|
|
|
function dbot.version.changelog.getCR()
|
|
|
|
|
|
|
|
|
|
|
|
if (dbot.version.changeLogPkg == nil) then
|
|
|
|
if (dbot.version.changelog.pkg == nil) then
|
|
|
|
dbot.error("dbot.version.changelogCR: Change log package is missing!")
|
|
|
|
dbot.error("dbot.version.changelog.getCR: Change log package is missing!")
|
|
|
|
return inv.tags.stop(invTagsVersion, "missing end tag", DRL_RET_INTERNAL_ERROR)
|
|
|
|
return inv.tags.stop(invTagsVersion, "missing end tag", DRL_RET_INTERNAL_ERROR)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
local fileData, retval = dbot.remote.get(dbot.version.changeLogPkg.url, dbot.version.changeLogPkg.protocol)
|
|
|
|
local fileData, retval = dbot.remote.get(dbot.version.changelog.pkg.url,
|
|
|
|
|
|
|
|
dbot.version.changelog.pkg.protocol)
|
|
|
|
if (retval ~= DRL_RET_SUCCESS) then
|
|
|
|
if (retval ~= DRL_RET_SUCCESS) then
|
|
|
|
dbot.warn("dbot.version.changelogCR: Failed to retrieve remote changelog file: " ..
|
|
|
|
dbot.warn("dbot.version.changelog.getCR: Failed to retrieve remote changelog file: " ..
|
|
|
|
dbot.retval.getString(retval))
|
|
|
|
dbot.retval.getString(retval))
|
|
|
|
elseif (fileData == nil) then
|
|
|
|
elseif (fileData == nil) then
|
|
|
|
dbot.info("No changelog information was found.")
|
|
|
|
dbot.info("No changelog information was found.")
|
|
|
@ -19617,48 +19627,47 @@ function dbot.version.changelogCR()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
loadstring(fileData)()
|
|
|
|
loadstring(fileData)()
|
|
|
|
if (dbot.changelog == nil) then
|
|
|
|
if (dbot.changelog == nil) then
|
|
|
|
dbot.warn("dbot.version.changelogCR: Invalid changelog format detected")
|
|
|
|
dbot.warn("dbot.version.changelog.getCR: Invalid changelog format detected")
|
|
|
|
retval = DRL_RET_INTERNAL_ERROR
|
|
|
|
retval = DRL_RET_INTERNAL_ERROR
|
|
|
|
else
|
|
|
|
else
|
|
|
|
retval = dbot.version.displayChanges(dbot.version.changeLogPkg.minVersion, dbot.changelog)
|
|
|
|
retval = dbot.version.changelog.displayChanges(dbot.version.changelog.pkg.minVersion, dbot.changelog)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
dbot.version.changeLogPkg = nil
|
|
|
|
dbot.version.changelog.pkg = nil
|
|
|
|
|
|
|
|
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, retval)
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, retval)
|
|
|
|
|
|
|
|
|
|
|
|
end -- dbot.version.changelogCR
|
|
|
|
end -- dbot.version.changelog.getCR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dbot.version.displayChanges(minVersion, changeLog)
|
|
|
|
function dbot.version.changelog.displayChanges(minVersion, changeLog)
|
|
|
|
local sortedLog = {}
|
|
|
|
local sortedLog = {}
|
|
|
|
|
|
|
|
|
|
|
|
for k, v in pairs(changeLog) do
|
|
|
|
for k, v in pairs(changeLog) do
|
|
|
|
table.insert(sortedLog, { version = tonumber(k) or 0, changes = v})
|
|
|
|
table.insert(sortedLog, { version = tonumber(k) or 0, changes = v})
|
|
|
|
end -- for
|
|
|
|
end -- for
|
|
|
|
|
|
|
|
table.sort(sortedLog, function (v1, v2) return v1.version < v2.version end)
|
|
|
|
table.sort(sortedLog, function (v1, v2) return v1.version > v2.version end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, clog in ipairs(sortedLog) do
|
|
|
|
for _, clog in ipairs(sortedLog) do
|
|
|
|
if (clog.version > minVersion) then
|
|
|
|
if (clog.version > minVersion) then
|
|
|
|
dbot.version.displayChange(clog)
|
|
|
|
dbot.version.changelog.displayChange(clog)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
end -- for
|
|
|
|
end -- for
|
|
|
|
|
|
|
|
|
|
|
|
return DRL_RET_SUCCESS
|
|
|
|
return DRL_RET_SUCCESS
|
|
|
|
end -- dbot.version.displayChanges
|
|
|
|
end -- dbot.version.changelog.displayChanges
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Format of entry is: { version = 2.0004,
|
|
|
|
-- Format of entry is: { version = 2.0004,
|
|
|
|
-- changes = { { change = drlDbotChangeLogTypeXYZ, desc = "what changed" }
|
|
|
|
-- changes = { { change = drlDbotChangeLogTypeXYZ, desc = "what changed" }
|
|
|
|
-- }
|
|
|
|
-- }
|
|
|
|
-- }
|
|
|
|
-- }
|
|
|
|
function dbot.version.displayChange(changeLogEntries)
|
|
|
|
function dbot.version.changelog.displayChange(changeLogEntries)
|
|
|
|
local retval = DRL_RET_SUCCESS
|
|
|
|
local retval = DRL_RET_SUCCESS
|
|
|
|
|
|
|
|
|
|
|
|
if (changeLogEntries == nil) then
|
|
|
|
if (changeLogEntries == nil) then
|
|
|
|
dbot.warn("dbot.version.displayChange: Change entries are missing!")
|
|
|
|
dbot.warn("dbot.version.changelog.displayChange: Change entries are missing!")
|
|
|
|
return DRL_RET_INVALID_PARAM
|
|
|
|
return DRL_RET_INVALID_PARAM
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
@ -19668,84 +19677,59 @@ function dbot.version.displayChange(changeLogEntries)
|
|
|
|
end -- for
|
|
|
|
end -- for
|
|
|
|
|
|
|
|
|
|
|
|
return retval
|
|
|
|
return retval
|
|
|
|
end -- dbot.version.displayChange
|
|
|
|
end -- dbot.version.changelog.displayChange
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--FIXME: rename this version.update???
|
|
|
|
|
|
|
|
dbot.update = {}
|
|
|
|
|
|
|
|
dbot.update.url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.xml"
|
|
|
|
|
|
|
|
dbot.update.protocol = "HTTPS"
|
|
|
|
|
|
|
|
dbot.update.pkg = nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drlDbotUpdateCheck = "check"
|
|
|
|
function dbot.version.update.release(mode, endTag)
|
|
|
|
drlDbotUpdateInstall = "install"
|
|
|
|
local url = "https://raw.githubusercontent.com/Aardurel/aard-plugins/master/aard_inventory.xml"
|
|
|
|
|
|
|
|
local protocol = "HTTPS"
|
|
|
|
function dbot.update.version(mode, endTag)
|
|
|
|
|
|
|
|
local retval = DRL_RET_SUCCESS
|
|
|
|
local retval = DRL_RET_SUCCESS
|
|
|
|
|
|
|
|
|
|
|
|
if (mode == nil) or ((mode ~= drlDbotUpdateCheck) and (mode ~= drlDbotUpdateInstall)) then
|
|
|
|
if (mode == nil) or ((mode ~= drlDbotUpdateCheck) and (mode ~= drlDbotUpdateInstall)) then
|
|
|
|
dbot.warn("dbot.update.version: Missing or invalid mode parameter")
|
|
|
|
dbot.warn("dbot.version.update.release: Missing or invalid mode parameter")
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_INVALID_PARAM)
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_INVALID_PARAM)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
if (dbot.update.pkg ~= nil) then
|
|
|
|
if (dbot.version.update.pkg ~= nil) then
|
|
|
|
dbot.info("Skipping update request: another update request is in progress")
|
|
|
|
dbot.info("Skipping update request: another update request is in progress")
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_BUSY)
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_BUSY)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
-- Pull in the async package if it exists
|
|
|
|
dbot.version.update.pkg = {}
|
|
|
|
local asyncOk, async = pcall (require, "async")
|
|
|
|
dbot.version.update.pkg.mode = mode
|
|
|
|
if (not asyncOk) or (async == nil) then
|
|
|
|
dbot.version.update.pkg.url = url
|
|
|
|
dbot.warn("dbot.update.version: Failed to find \"async\" package, skipping update request")
|
|
|
|
dbot.version.update.pkg.protocol = protocol
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, DRL_RET_UNSUPPORTED)
|
|
|
|
dbot.version.update.pkg.endTag = endTag
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbot.update.pkg = {}
|
|
|
|
|
|
|
|
dbot.update.pkg.mode = mode
|
|
|
|
|
|
|
|
dbot.update.pkg.endTag = endTag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Make a request to grab the latest plugin file. Newer versions of mush have nice async
|
|
|
|
wait.make(dbot.version.update.releaseCR)
|
|
|
|
-- capabilities and we use that if possible. Otherwise, we fall back to an old-style request.
|
|
|
|
|
|
|
|
-- Both methods of making the request will call dbot.update.callback upon completion.
|
|
|
|
|
|
|
|
if (async.doAsyncRemoveRequest ~= nil) then
|
|
|
|
|
|
|
|
async.doAsyncRemoteRequest(dbot.update.url, dbot.update.callback, dbot.update.protocol)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
wait.make(dbot.updateCR) -- Fall back to a co-routine running the old-style async code
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return retval
|
|
|
|
return retval
|
|
|
|
end -- dbot.update
|
|
|
|
end -- dbot.version.update.release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Scan the file we just (hopefully) downloaded and check the file's version. If the user
|
|
|
|
function dbot.version.update.releaseCR()
|
|
|
|
-- requested a version check, we report the current and latest available versions. If the
|
|
|
|
|
|
|
|
-- user requested an installation of the latest plugin, do the upgrade if everything looks
|
|
|
|
|
|
|
|
-- sane.
|
|
|
|
|
|
|
|
function dbot.update.callback(retval, page, status, headers, fullStatus, requestUrl)
|
|
|
|
|
|
|
|
local retval = DRL_RET_SUCCESS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dbot.update.pkg == nil) or (dbot.update.pkg.mode == nil) then
|
|
|
|
if (dbot.version.update.pkg == nil) or (dbot.version.update.pkg.mode == nil) then
|
|
|
|
dbot.error("dbot.update.callback: Missing or invalid update package detected")
|
|
|
|
dbot.error("dbot.version.update.releaseCR: Missing or invalid update package detected")
|
|
|
|
return inv.tags.stop(invTagsVersion, "end tag is nil", DRL_RET_INVALID_PARAM)
|
|
|
|
return inv.tags.stop(invTagsVersion, "end tag is nil", DRL_RET_INVALID_PARAM)
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
local endTag = dbot.update.pkg.endTag
|
|
|
|
local endTag = dbot.version.update.pkg.endTag
|
|
|
|
|
|
|
|
|
|
|
|
if (status ~= 200) then
|
|
|
|
-- This blocks until the plugin file is returned, an error is detected, or we time out
|
|
|
|
dbot.warn("dbot.update.callback: Failed to retrieve remote plugin information")
|
|
|
|
local pluginData, retval = dbot.remote.get(dbot.version.update.pkg.url, dbot.version.update.pkg.protocol)
|
|
|
|
retval = DRL_RET_INTERNAL_ERROR
|
|
|
|
if (retval ~= DRL_RET_SUCCESS) then
|
|
|
|
|
|
|
|
dbot.warn("dbot.version.update.releaseCR: Failed to retrieve latest plugin file: " ..
|
|
|
|
|
|
|
|
dbot.retval.getString(retval))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif (pluginData == nil) then
|
|
|
|
|
|
|
|
dbot.info("Could not find a remote plugin release")
|
|
|
|
|
|
|
|
retval = DRL_RET_MISSING_ENTRY
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local currentVersion = GetPluginInfo(GetPluginID(), 19) or 0
|
|
|
|
local currentVersion = GetPluginInfo(GetPluginID(), 19) or 0
|
|
|
|
local currentVerStr = string.format("%1.4f", currentVersion)
|
|
|
|
local currentVerStr = string.format("%1.4f", currentVersion)
|
|
|
|
local remoteVerStr = string.match(page, '%s%s+version="([0-9%.]+)"')
|
|
|
|
local remoteVerStr = string.match(pluginData, '%s%s+version="([0-9%.]+)"')
|
|
|
|
local remoteVersion = tonumber(remoteVerStr or "") or 0
|
|
|
|
local remoteVersion = tonumber(remoteVerStr or "") or 0
|
|
|
|
|
|
|
|
|
|
|
|
if (remoteVersion == currentVersion) then
|
|
|
|
if (remoteVersion == currentVersion) then
|
|
|
@ -19756,68 +19740,34 @@ function dbot.update.callback(retval, page, status, headers, fullStatus, request
|
|
|
|
"is newer than the latest official release (v" .. remoteVerStr .. ")")
|
|
|
|
"is newer than the latest official release (v" .. remoteVerStr .. ")")
|
|
|
|
retval = DRL_RET_VER_MISMATCH
|
|
|
|
retval = DRL_RET_VER_MISMATCH
|
|
|
|
|
|
|
|
|
|
|
|
elseif (dbot.update.pkg.mode == drlDbotUpdateCheck) then
|
|
|
|
elseif (dbot.version.update.pkg.mode == drlDbotUpdateCheck) then
|
|
|
|
dbot.info("You are running v" .. currentVerStr .. ", latest version is v" .. remoteVerStr)
|
|
|
|
dbot.info("You are running v" .. currentVerStr .. ", latest version is v" .. remoteVerStr)
|
|
|
|
dbot.info("Changes since your last update:")
|
|
|
|
dbot.info("Changes since your last update:")
|
|
|
|
dbot.update.pkg = nil
|
|
|
|
dbot.version.update.pkg = nil
|
|
|
|
return dbot.version.changelog(currentVersion, endTag)
|
|
|
|
return dbot.version.changelog.get(currentVersion, endTag)
|
|
|
|
|
|
|
|
|
|
|
|
elseif (dbot.update.pkg.mode == drlDbotUpdateInstall) then
|
|
|
|
elseif (dbot.version.update.pkg.mode == drlDbotUpdateInstall) then
|
|
|
|
dbot.info("Updating plugin from version " .. currentVerStr .. " to version " .. remoteVerStr)
|
|
|
|
dbot.info("Updating plugin from version " .. currentVerStr .. " to version " .. remoteVerStr)
|
|
|
|
dbot.info("Please do not enter anything until the update completes")
|
|
|
|
dbot.info("Please do not enter anything until the update completes")
|
|
|
|
|
|
|
|
|
|
|
|
local pluginFile = GetPluginInfo(GetPluginID(), 6)
|
|
|
|
local pluginFile = GetPluginInfo(GetPluginID(), 6)
|
|
|
|
local file = io.open(pluginFile, "w")
|
|
|
|
local file = io.open(pluginFile, "w")
|
|
|
|
file:write(page)
|
|
|
|
file:write(pluginData)
|
|
|
|
file:close()
|
|
|
|
file:close()
|
|
|
|
dbot.reload()
|
|
|
|
dbot.reload()
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
dbot.error("dbot.update.callback: Detected invalid mode \"@R" .. (dbot.update.pkg.mode or "nil") ..
|
|
|
|
dbot.error("dbot.version.update.callback: Detected invalid mode \"@R" ..
|
|
|
|
"@W\"")
|
|
|
|
(dbot.version.update.pkg.mode or "nil") .. "@W\"")
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
end -- if
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
dbot.update.pkg = nil
|
|
|
|
dbot.version.update.pkg = nil
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, retval)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end -- dbot.update.callback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dbot.updateCR()
|
|
|
|
|
|
|
|
local urlThread = async.request(dbot.update.url, dbot.update.protocol)
|
|
|
|
|
|
|
|
local updateRet, page, status, headers, fullStatus = -1, nil, -1, nil, nil, dbot.update.url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (urlThread == nil) then
|
|
|
|
|
|
|
|
dbot.warn("dbot.updateCR: Failed to create thread requesting update")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local timeout = 10
|
|
|
|
|
|
|
|
local totTime = 0
|
|
|
|
|
|
|
|
while (urlThread:alive()) do
|
|
|
|
|
|
|
|
if (totTime > timeout) then
|
|
|
|
|
|
|
|
retval = DRL_RET_TIMEOUT
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wait.time(drlSpinnerPeriodDefault)
|
|
|
|
|
|
|
|
totTime = totTime + drlSpinnerPeriodDefault
|
|
|
|
|
|
|
|
end -- while
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--FIXME: this is broken!!! retval is never defined!!!
|
|
|
|
|
|
|
|
if (retval ~= DRL_RET_SUCCESS) then
|
|
|
|
|
|
|
|
updateRet, page, status, headers, fullStatus = urlThread:join()
|
|
|
|
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end -- if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbot.update.callback(updateRet, page, status, headers, fullStatus)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end -- dbot.updateCR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return inv.tags.stop(invTagsVersion, endTag, retval)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end -- dbot.version.update.releaseCR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
|