improve android upgrade interface
and refactor
This commit is contained in:
parent
e563c7e6f4
commit
fda641d27b
3 changed files with 42 additions and 29 deletions
|
@ -20,6 +20,11 @@ import Annex.Content
|
||||||
import qualified Backend
|
import qualified Backend
|
||||||
import qualified Types.Backend
|
import qualified Types.Backend
|
||||||
import qualified Types.Key
|
import qualified Types.Key
|
||||||
|
import Assistant.TransferQueue
|
||||||
|
import Assistant.TransferSlots
|
||||||
|
import Remote
|
||||||
|
|
||||||
|
import qualified Data.Map as M
|
||||||
|
|
||||||
{- Upgrade without interaction in the webapp. -}
|
{- Upgrade without interaction in the webapp. -}
|
||||||
unattendedUpgrade :: Assistant ()
|
unattendedUpgrade :: Assistant ()
|
||||||
|
@ -46,6 +51,27 @@ checkSuccessfulUpgrade = isJust <$> getEnv upgradedEnv
|
||||||
upgradedEnv :: String
|
upgradedEnv :: String
|
||||||
upgradedEnv = "GIT_ANNEX_UPGRADED"
|
upgradedEnv = "GIT_ANNEX_UPGRADED"
|
||||||
|
|
||||||
|
{- Start downloading the distribution key from the web.
|
||||||
|
- Install a hook that will be run once the download is complete. -}
|
||||||
|
startDistributionDownload :: GitAnnexDistribution -> Assistant ()
|
||||||
|
startDistributionDownload d = do
|
||||||
|
liftAnnex $ setUrlPresent k u
|
||||||
|
hook <- asIO1 $ distributionDownloadComplete d
|
||||||
|
modifyDaemonStatus_ $ \status -> status
|
||||||
|
{ transferHook = M.insert k hook (transferHook status) }
|
||||||
|
maybe noop (queueTransfer "upgrade" Next (Just f) t)
|
||||||
|
=<< liftAnnex (remoteFromUUID webUUID)
|
||||||
|
startTransfer t
|
||||||
|
where
|
||||||
|
k = distributionKey d
|
||||||
|
u = distributionUrl d
|
||||||
|
f = takeFileName u ++ " (for upgrade)"
|
||||||
|
t = Transfer
|
||||||
|
{ transferDirection = Download
|
||||||
|
, transferUUID = webUUID
|
||||||
|
, transferKey = k
|
||||||
|
}
|
||||||
|
|
||||||
{- Fsck the key to verify the download. -}
|
{- Fsck the key to verify the download. -}
|
||||||
distributionDownloadComplete :: GitAnnexDistribution -> Transfer -> Assistant ()
|
distributionDownloadComplete :: GitAnnexDistribution -> Transfer -> Assistant ()
|
||||||
distributionDownloadComplete d t
|
distributionDownloadComplete d t
|
||||||
|
|
|
@ -13,43 +13,21 @@ import Assistant.WebApp.Common
|
||||||
import Types.Distribution
|
import Types.Distribution
|
||||||
import Assistant.Upgrade
|
import Assistant.Upgrade
|
||||||
import Assistant.Restart
|
import Assistant.Restart
|
||||||
import Assistant.DaemonStatus
|
|
||||||
import Config
|
import Config
|
||||||
import Assistant.TransferQueue
|
|
||||||
import Assistant.TransferSlots
|
|
||||||
import Logs.Transfer
|
|
||||||
import Logs.Web
|
|
||||||
import Remote
|
|
||||||
|
|
||||||
import qualified Data.Map as M
|
{- On Android, just point the user at the apk file to download.
|
||||||
|
- Installation will be handled by selecting the downloaded file.
|
||||||
{- On Android, just redirect the user's web browser to the apk file
|
|
||||||
- to download it.
|
|
||||||
-
|
-
|
||||||
- Otherwise, register a hook action that will be called once the key
|
- Otherwise, start the download.
|
||||||
- is downloaded, and start downloading the key.
|
|
||||||
- -}
|
- -}
|
||||||
getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
|
getConfigStartUpgradeR :: GitAnnexDistribution -> Handler Html
|
||||||
getConfigStartUpgradeR d = do
|
getConfigStartUpgradeR d = do
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
redirect (distributionUrl d)
|
let url = distributionUrl d
|
||||||
|
page "Upgrade" (Just Configuration) $
|
||||||
|
$(widgetFile "configurators/upgrade/android")
|
||||||
#else
|
#else
|
||||||
liftAssistant $ do
|
liftAssistant $ startDistributionDownload d
|
||||||
let k = distributionKey d
|
|
||||||
let u = distributionUrl d
|
|
||||||
liftAnnex $ setUrlPresent k u
|
|
||||||
hook <- asIO1 $ distributionDownloadComplete d
|
|
||||||
modifyDaemonStatus_ $ \status -> status
|
|
||||||
{ transferHook = M.insert k hook (transferHook status) }
|
|
||||||
let t = Transfer
|
|
||||||
{ transferDirection = Download
|
|
||||||
, transferUUID = webUUID
|
|
||||||
, transferKey = k
|
|
||||||
}
|
|
||||||
let f = takeFileName u ++ " (for upgrade)"
|
|
||||||
maybe noop (queueTransfer "upgrade" Next (Just f) t)
|
|
||||||
=<< liftAnnex (remoteFromUUID webUUID)
|
|
||||||
startTransfer t
|
|
||||||
redirect DashboardR
|
redirect DashboardR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
9
templates/configurators/upgrade/android.hamlet
Normal file
9
templates/configurators/upgrade/android.hamlet
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<div .span9 .hero-unit>
|
||||||
|
<h2>
|
||||||
|
Upgrading git-annex
|
||||||
|
<p>
|
||||||
|
To start the upgrade #
|
||||||
|
<a .btn .btn-primary href="#{url}">
|
||||||
|
Download #{takeFileName url}
|
||||||
|
<p>
|
||||||
|
Once the download is complete, open the file to upgrade git-annex.
|
Loading…
Add table
Add a link
Reference in a new issue