Browse Source

check for permissions to update at a better time

Alan Shreve 11 years ago
parent
commit
e3901cc777
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/ngrok/client/update_release.go

+ 7 - 5
src/ngrok/client/update_release.go

@@ -33,10 +33,6 @@ func autoUpdate(s mvc.State, token string) {
 		return
 		return
 	}
 	}
 
 
-	if err := up.CanUpdate(); err != nil {
-		log.Error("Can't update: insufficient permissions: %v", err)
-	}
-
 	update := func() (tryAgain bool) {
 	update := func() (tryAgain bool) {
 		log.Info("Checking for update")
 		log.Info("Checking for update")
 		params := check.Params{
 		params := check.Params{
@@ -55,7 +51,13 @@ func autoUpdate(s mvc.State, token string) {
 		}
 		}
 
 
 		if result.Initiative == check.INITIATIVE_AUTO {
 		if result.Initiative == check.INITIATIVE_AUTO {
-			applyUpdate(s, result)
+			if err := up.CanUpdate(); err != nil {
+				log.Error("Can't update: insufficient permissions: %v", err)
+				// tell the user to update manually
+				s.SetUpdateStatus(mvc.UpdateAvailable)
+			} else {
+				applyUpdate(s, result)
+			}
 		} else if result.Initiative == check.INITIATIVE_MANUAL {
 		} else if result.Initiative == check.INITIATIVE_MANUAL {
 			// this is the way the server tells us to update manually
 			// this is the way the server tells us to update manually
 			log.Info("Server wants us to update manually")
 			log.Info("Server wants us to update manually")