This commit is contained in:
Joey Hess 2015-08-17 10:42:14 -04:00
parent 2ff22a383a
commit 1cd3b7ddf0
7 changed files with 21 additions and 10 deletions

View file

@ -18,6 +18,7 @@ import qualified Git
import Config import Config
import Config.Cost import Config.Cost
import Remote.Helper.Special import Remote.Helper.Special
import Remote.Helper.Messages
import qualified Remote.Helper.AWS as AWS import qualified Remote.Helper.AWS as AWS
import Creds import Creds
import Utility.Metered import Utility.Metered
@ -176,7 +177,7 @@ remove r k = glacierAction r
checkKey :: Remote -> CheckPresent checkKey :: Remote -> CheckPresent
checkKey r k = do checkKey r k = do
showAction $ "checking " ++ name r showChecking r
go =<< glacierEnv (config r) (uuid r) go =<< glacierEnv (config r) (uuid r)
where where
go Nothing = error "cannot check glacier" go Nothing = error "cannot check glacier"

View file

@ -5,15 +5,14 @@
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
module Remote.Helper.Messages where module Remote.Helper.Messages where
import Common.Annex import Common.Annex
import qualified Git import qualified Git
import qualified Types.Remote as Remote import qualified Types.Remote as Remote
showChecking :: Git.Repo -> Annex ()
showChecking r = showAction $ "checking " ++ Git.repoDescribe r
class Checkable a where class Checkable a where
descCheckable :: a -> String descCheckable :: a -> String
@ -23,5 +22,11 @@ instance Checkable Git.Repo where
instance Checkable (Remote.RemoteA a) where instance Checkable (Remote.RemoteA a) where
descCheckable = Remote.name descCheckable = Remote.name
instance Checkable String where
descCheckable = id
showChecking :: Checkable a => a -> Annex ()
showChecking v = showAction $ "checking " ++ descCheckable v
cantCheck :: Checkable a => a -> e cantCheck :: Checkable a => a -> e
cantCheck v = error $ "unable to check " ++ descCheckable v cantCheck v = error $ "unable to check " ++ descCheckable v

View file

@ -16,6 +16,7 @@ import Config
import Config.Cost import Config.Cost
import Annex.UUID import Annex.UUID
import Remote.Helper.Special import Remote.Helper.Special
import Remote.Helper.Messages
import Utility.Env import Utility.Env
import Messages.Progress import Messages.Progress
@ -138,7 +139,7 @@ remove h k = runHook h "remove" k Nothing $ return True
checkKey :: Git.Repo -> HookName -> CheckPresent checkKey :: Git.Repo -> HookName -> CheckPresent
checkKey r h k = do checkKey r h k = do
showAction $ "checking " ++ Git.repoDescribe r showChecking r
v <- lookupHook h action v <- lookupHook h action
liftIO $ check v liftIO $ check v
where where

View file

@ -27,6 +27,7 @@ import Annex.Content
import Annex.UUID import Annex.UUID
import Annex.Ssh import Annex.Ssh
import Remote.Helper.Special import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Rsync.RsyncUrl import Remote.Rsync.RsyncUrl
import Crypto import Crypto
import Utility.Rsync import Utility.Rsync
@ -222,7 +223,7 @@ remove o k = do
checkKey :: Git.Repo -> RsyncOpts -> CheckPresent checkKey :: Git.Repo -> RsyncOpts -> CheckPresent
checkKey r o k = do checkKey r o k = do
showAction $ "checking " ++ Git.repoDescribe r showChecking r
-- note: Does not currently differentiate between rsync failing -- note: Does not currently differentiate between rsync failing
-- to connect, and the file not being present. -- to connect, and the file not being present.
untilTrue (rsyncUrls o k) $ \u -> untilTrue (rsyncUrls o k) $ \u ->

View file

@ -39,6 +39,7 @@ import Config
import Config.Cost import Config.Cost
import Remote.Helper.Special import Remote.Helper.Special
import Remote.Helper.Http import Remote.Helper.Http
import Remote.Helper.Messages
import qualified Remote.Helper.AWS as AWS import qualified Remote.Helper.AWS as AWS
import Creds import Creds
import Annex.UUID import Annex.UUID
@ -269,7 +270,7 @@ remove info h k
checkKey :: Remote -> S3Info -> Maybe S3Handle -> CheckPresent checkKey :: Remote -> S3Info -> Maybe S3Handle -> CheckPresent
checkKey r info (Just h) k = do checkKey r info (Just h) k = do
showAction $ "checking " ++ name r showChecking r
#if MIN_VERSION_aws(0,10,0) #if MIN_VERSION_aws(0,10,0)
rsp <- go rsp <- go
return (isJust $ S3.horMetadata rsp) return (isJust $ S3.horMetadata rsp)
@ -300,7 +301,7 @@ checkKey r info Nothing k = case getpublicurl info of
warnMissingCredPairFor "S3" (AWS.creds $ uuid r) warnMissingCredPairFor "S3" (AWS.creds $ uuid r)
error "No S3 credentials configured" error "No S3 credentials configured"
Just geturl -> do Just geturl -> do
showAction $ "checking " ++ name r showChecking r
withUrlOptions $ checkBoth (geturl k) (keySize k) withUrlOptions $ checkBoth (geturl k) (keySize k)
{- Generate the bucket if it does not already exist, including creating the {- Generate the bucket if it does not already exist, including creating the

View file

@ -11,6 +11,7 @@ module Remote.Web (remote) where
import Common.Annex import Common.Annex
import Types.Remote import Types.Remote
import Remote.Helper.Messages
import qualified Git import qualified Git
import qualified Git.Construct import qualified Git.Construct
import Annex.Content import Annex.Content
@ -112,7 +113,7 @@ checkKey key = do
checkKey' :: Key -> [URLString] -> Annex (Either String Bool) checkKey' :: Key -> [URLString] -> Annex (Either String Bool)
checkKey' key us = firsthit us (Right False) $ \u -> do checkKey' key us = firsthit us (Right False) $ \u -> do
let (u', downloader) = getDownloader u let (u', downloader) = getDownloader u
showAction $ "checking " ++ u' showChecking u'
case downloader of case downloader of
QuviDownloader -> QuviDownloader ->
#ifdef WITH_QUVI #ifdef WITH_QUVI

View file

@ -25,6 +25,7 @@ import qualified Git
import Config import Config
import Config.Cost import Config.Cost
import Remote.Helper.Special import Remote.Helper.Special
import Remote.Helper.Messages
import Remote.Helper.Http import Remote.Helper.Http
import qualified Remote.Helper.Chunked.Legacy as Legacy import qualified Remote.Helper.Chunked.Legacy as Legacy
import Creds import Creds
@ -147,7 +148,7 @@ remove (Just dav) k = liftIO $ do
checkKey :: Remote -> ChunkConfig -> Maybe DavHandle -> CheckPresent checkKey :: Remote -> ChunkConfig -> Maybe DavHandle -> CheckPresent
checkKey r _ Nothing _ = error $ name r ++ " not configured" checkKey r _ Nothing _ = error $ name r ++ " not configured"
checkKey r chunkconfig (Just dav) k = do checkKey r chunkconfig (Just dav) k = do
showAction $ "checking " ++ name r showChecking r
case chunkconfig of case chunkconfig of
LegacyChunks _ -> checkKeyLegacyChunked dav k LegacyChunks _ -> checkKeyLegacyChunked dav k
_ -> do _ -> do