Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from Sonoran-Software/release/4.0.1
Browse files Browse the repository at this point in the history
Release/2.4.1
  • Loading branch information
nathanctech authored Jan 30, 2021
2 parents 03cf416 + 113cc1a commit b90bf42
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion sonorancad/core/http.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { format } = require("path");

function byteCount(s) {
return encodeURI(s).split(/%..|./).length - 1;
}

exports('HandleHttpRequest', (dest, callback, method, data, headers) => {
emit("SonoranCAD::core:writeLog", "debug", "[http] to: " + dest + " - data: " + dest, JSON.stringify(data));
const urlObj = url.parse(dest)
const options = {
hostname: urlObj.hostname,
Expand Down Expand Up @@ -30,7 +33,7 @@ exports('HandleHttpRequest', (dest, callback, method, data, headers) => {
})

req.on('error', (error) => {
console.error(error);
console.error("HTTP error caught: " + JSON.stringify(error));
})
if (method == "POST") {
req.write(data);
Expand Down
7 changes: 5 additions & 2 deletions sonorancad/core/plugin_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ local function downloadPlugin(name, url)
local releaseUrl = ("%s/archive/latest.zip"):format(url)
PerformHttpRequest(releaseUrl, function(code, data, headers)
if code == 200 then
exports[GetCurrentResourceName()]:CreateFolderIfNotExisting(GetResourcePath(GetCurrentResourceName()).."/pluginupdates/")
local savePath = GetResourcePath(GetCurrentResourceName()).."/pluginupdates/"..name..".zip"
local f = assert(io.open(savePath, 'wb'))
f:write(data)
Expand All @@ -62,7 +63,7 @@ function CheckForPluginUpdate(name, checkUrl)
if plugin == nil then
errorLog(("Plugin %s not found."):format(name))
return
elseif plugin.check_url == nil then
elseif plugin.check_url == nil or plugin.check_url == "" then
warnLog(("Plugin %s does not have check_url set. Please update it manually."):format(name))
return
end
Expand All @@ -79,14 +80,16 @@ function CheckForPluginUpdate(name, checkUrl)
local localVersion = string.gsub(plugin.version, "%.", "")
if localVersion < latestVersion then
warnLog(("Plugin Updater: %s has an available update! %s -> %s"):format(name, plugin.version, remote.version))
if remote.download_url ~= nil then
if remote.download_url ~= nil and remote.download_url ~= "" then
if Config.allowAutoUpdate then
infoLog(("Attempting to automatically update %s..."):format(name))
downloadPlugin(name, remote.download_url)
PluginsWereUpdated = true
else
warnLog("Automatic updates are disabled. Please update this plugin ASAP.")
end
else
warnLog(("Plugin %s does not have download_url set. Please update it manually."):format(name))
end
end
if remote.configVersion ~= nil then
Expand Down
6 changes: 6 additions & 0 deletions sonorancad/core/unzipper/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ exports('UnzipFolder', (file, name, dest) => {
entry.autodrain();
}
})
});

exports('CreateFolderIfNotExisting', (path) => {
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
});
Empty file removed sonorancad/pluginupdates/.gitkeep
Empty file.

0 comments on commit b90bf42

Please sign in to comment.