Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Add logs to GithubCheckUpdates
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran committed Oct 20, 2017
1 parent f227a31 commit 7e2b7f4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deduplicator.lrdevplugin/GithubCheckUpdates.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
local LrDialogs = import 'LrDialogs'
local LrHttp = import 'LrHttp'
local LrLogger = import 'LrLogger'
local LrTasks = import 'LrTasks'

local json = require 'JSON'
json.strictTypes = true

require 'Info'

local logger = LrLogger('Deduplicator')
logger:enable('logfile')

logger:trace('GithubCheckUpdates.lua invoked')

function checkForUpdates()
logger:debugf('Preparing to request %s', latestReleaseJsonUrl)
local responseBody, headers = LrHttp.get(latestReleaseJsonUrl)
r = json:decode(responseBody)
logger:infof('Received latest available version as %s', r['tag_name'])
if r['tag_name'] ~= plugin_version then
local referToNewRelease = LrDialogs.confirm(
'Update is available!',
Expand All @@ -19,9 +27,13 @@ function checkForUpdates()
)

if referToNewRelease == 'ok' then
logger:tracef('Opening %s in system browser', r['html_url'])
LrHttp.openUrlInBrowser(r['html_url'])
else
logger:tracef("User refused to update :'(")
end
else
logger:infof('Deduplicator is up-to-date')
LrDialogs.message('Deduplicator is up-to-date!', 'Keep it going!')
end
end
Expand Down

0 comments on commit 7e2b7f4

Please sign in to comment.