diff options
-rw-r--r-- | Assistant.hs | 2 | ||||
-rw-r--r-- | Assistant/Threads/UpgradeWatcher.hs | 8 | ||||
-rw-r--r-- | Assistant/Threads/Upgrader.hs | 26 | ||||
-rw-r--r-- | doc/assistant/upgradecomplete.png | bin | 0 -> 4817 bytes |
4 files changed, 22 insertions, 14 deletions
diff --git a/Assistant.hs b/Assistant.hs index 6b6b98ebc..d4786f99a 100644 --- a/Assistant.hs +++ b/Assistant.hs @@ -153,7 +153,7 @@ startDaemon assistant foreground startdelay cannotrun listenhost startbrowser = #endif , assist $ netWatcherThread , assist $ upgraderThread urlrenderer - , assist $ upgradWatcherThread urlrenderer + , assist $ upgradeWatcherThread urlrenderer , assist $ netWatcherFallbackThread , assist $ transferScannerThread urlrenderer , assist $ cronnerThread urlrenderer diff --git a/Assistant/Threads/UpgradeWatcher.hs b/Assistant/Threads/UpgradeWatcher.hs index c127e3b2f..80b11e71a 100644 --- a/Assistant/Threads/UpgradeWatcher.hs +++ b/Assistant/Threads/UpgradeWatcher.hs @@ -8,7 +8,7 @@ {-# LANGUAGE CPP #-} module Assistant.Threads.UpgradeWatcher ( - upgradWatcherThread + upgradeWatcherThread ) where import Assistant.Common @@ -30,9 +30,9 @@ import qualified Data.Text as T data WatcherState = InStartupScan | Started | Upgrading deriving (Eq) -upgradWatcherThread :: UrlRenderer -> NamedThread -upgradWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do - whenM (liftIO $ checkSuccessfulUpgrade) $ +upgradeWatcherThread :: UrlRenderer -> NamedThread +upgradeWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do + whenM (liftIO checkSuccessfulUpgrade) $ showSuccessfulUpgrade urlrenderer go =<< liftIO upgradeFlagFile where diff --git a/Assistant/Threads/Upgrader.hs b/Assistant/Threads/Upgrader.hs index 7a95a711d..95796be22 100644 --- a/Assistant/Threads/Upgrader.hs +++ b/Assistant/Threads/Upgrader.hs @@ -12,6 +12,8 @@ module Assistant.Threads.Upgrader ( ) where import Assistant.Common +import Assistant.Upgrade + import Assistant.Types.UrlRenderer import Assistant.DaemonStatus import Assistant.Alert @@ -31,11 +33,14 @@ import Data.Time.Clock import qualified Data.Text as T upgraderThread :: UrlRenderer -> NamedThread -upgraderThread urlrenderer = namedThread "Upgrader" $ do - checkUpgrade urlrenderer +upgraderThread urlrenderer = namedThread "Upgrader" $ when (isJust Build.SysConfig.upgradelocation) $ do + {- Check for upgrade on startup, unless it was just + - upgraded. -} + unlessM (liftIO checkSuccessfulUpgrade) $ + checkUpgrade urlrenderer h <- liftIO . newNotificationHandle False . networkConnectedNotifier =<< getDaemonStatus - go h Nothing + go h =<< liftIO getCurrentTime where {- Wait for a network connection event. Then see if it's been - half a day since the last upgrade check. If so, proceed with @@ -47,10 +52,10 @@ upgraderThread urlrenderer = namedThread "Upgrader" $ do then go h lastchecked else do now <- liftIO getCurrentTime - if maybe True (\t -> diffUTCTime now t > halfday) lastchecked + if diffUTCTime now lastchecked > halfday then do checkUpgrade urlrenderer - go h =<< Just <$> liftIO getCurrentTime + go h =<< liftIO getCurrentTime else go h lastchecked halfday = 12 * 60 * 60 @@ -71,13 +76,16 @@ checkUpgrade urlrenderer = do else debug [ "No new version found." ] canUpgrade :: AlertPriority -> UrlRenderer -> GitAnnexDistribution -> Assistant () -canUpgrade urgency urlrenderer d = do +canUpgrade urgency urlrenderer d = ifM autoUpgradeEnabled + ( startDistributionDownload d + , do #ifdef WITH_WEBAPP - button <- mkAlertButton True (T.pack "Upgrade") urlrenderer (ConfigStartUpgradeR d) - void $ addAlert (canUpgradeAlert urgency button) + button <- mkAlertButton True (T.pack "Upgrade") urlrenderer (ConfigStartUpgradeR d) + void $ addAlert (canUpgradeAlert urgency button) #else - noop + noop #endif + ) getDistributionInfo :: Assistant (Maybe GitAnnexDistribution) getDistributionInfo = do diff --git a/doc/assistant/upgradecomplete.png b/doc/assistant/upgradecomplete.png Binary files differnew file mode 100644 index 000000000..3f8c7f3c2 --- /dev/null +++ b/doc/assistant/upgradecomplete.png |