1{- git-annex assistant webapp upgrade UI
2 -
3 - Copyright 2013 Joey Hess <id@joeyh.name>
4 -
5 - Licensed under the GNU AGPL version 3 or higher.
6 -}
7
8{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-}
9
10module Assistant.WebApp.Configurators.Upgrade where
11
12import Assistant.WebApp.Common
13import Types.Distribution
14import Assistant.Upgrade
15import Assistant.Restart
16import Config
17
18{- Start the upgrade process. -}
19getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
20getConfigStartUpgradeR d = do
21	liftAssistant $ startDistributionDownload d
22	redirect DashboardR
23
24{- Finish upgrade by starting the new assistant in the same repository this
25 - one is running in, and redirecting to it. -}
26getConfigFinishUpgradeR :: Handler Html
27getConfigFinishUpgradeR = do
28	liftAssistant prepUpgrade
29	url <- liftAssistant runRestart
30	liftAssistant $ postUpgrade url
31	redirect url
32
33getConfigEnableAutomaticUpgradeR :: Handler Html
34getConfigEnableAutomaticUpgradeR = do
35	liftAnnex $ setConfig (annexConfig "autoupgrade")
36		(fromAutoUpgrade AutoUpgrade)
37	redirect DashboardR
38