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

Commit

Permalink
Stop polling if authentication fails; bump version
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
michaelsanford committed Mar 28, 2019
1 parent 168615b commit b4e2f3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.1.0-{build}
version: 1.1.1-{build}

clone_folder: c:\gopath\src\github.com\michaelsanford\bittray

Expand Down
2 changes: 1 addition & 1 deletion config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var (
// GhAPI is the GitHub URL to the Release API (for update checks)
GhAPI = "https://api.github.com/repos/michaelsanford/bittray/releases/latest"
// CurrentVersionTag is the git tag of the current version
CurrentVersionTag = "1.1.0"
CurrentVersionTag = "1.1.1"

// DocsURL is the GitHub URL to the documentation site
DocsURL = "https://michaelsanford.github.io/bittray/"
Expand Down
11 changes: 8 additions & 3 deletions polling/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ func Poll() <-chan int8 {
for ; true; <-ticker.C {
resp, _ := client.Do(req)

if resp != nil && resp.StatusCode == 200 {
bodyText, _ := ioutil.ReadAll(resp.Body)
items <- int8(gjson.Get(string(bodyText), "size").Uint())
if resp != nil {
if resp.StatusCode == 200 {
bodyText, _ := ioutil.ReadAll(resp.Body)
items <- int8(gjson.Get(string(bodyText), "size").Uint())
} else if resp.StatusCode == 401 {
ticker.Stop()
items <- int8(-2)
}
} else {
items <- int8(-1)
}
Expand Down
5 changes: 5 additions & 0 deletions tray/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func onReady() {
systray.SetTooltip("Locked")
dlgs.Error("Bitbucket Error", "There was a problem contacting the API")
}
} else if count == -2 {
systray.SetIcon(icon.Lock)
systray.SetTooltip("Not Authorized")
dlgs.Error("Not Authorized", "Wrong password. Quit and try again!")
systray.Quit()
}
}
}()
Expand Down

0 comments on commit b4e2f3a

Please sign in to comment.