improve android upgrade interface

and refactor
This commit is contained in:
Joey Hess 2013-11-23 22:12:36 -04:00
parent e563c7e6f4
commit fda641d27b
3 changed files with 42 additions and 29 deletions

View file

@ -20,6 +20,11 @@ import Annex.Content
import qualified Backend
import qualified Types.Backend
import qualified Types.Key
import Assistant.TransferQueue
import Assistant.TransferSlots
import Remote
import qualified Data.Map as M
{- Upgrade without interaction in the webapp. -}
unattendedUpgrade :: Assistant ()
@ -46,6 +51,27 @@ checkSuccessfulUpgrade = isJust <$> getEnv upgradedEnv
upgradedEnv :: String
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. -}
distributionDownloadComplete :: GitAnnexDistribution -> Transfer -> Assistant ()
distributionDownloadComplete d t