summaryrefslogtreecommitdiff
path: root/Remote/External.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-13 14:41:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-13 14:41:10 -0400
commitfa7934c035ff09b46d646353683c6d9745f0c94d (patch)
treeccdbbe618762679e9bc2932e8d92bbee86067fd9 /Remote/External.hs
parent2d9784fae4ea1830865bc77de1a1c4c1b4ce3714 (diff)
add GETAVAILABILITY to external special remote protocol
And some reworking of types, and added an annex-availability git config setting.
Diffstat (limited to 'Remote/External.hs')
-rw-r--r--Remote/External.hs23
1 files changed, 21 insertions, 2 deletions
diff --git a/Remote/External.hs b/Remote/External.hs
index 34810c4ac..26f511551 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -45,6 +45,7 @@ gen r u c gc = do
external <- newExternal externaltype u c
Annex.addCleanup (fromUUID u) $ stopExternal external
cst <- getCost external r gc
+ avail <- getAvailability external r gc
return $ Just $ encryptableRemote c
(storeEncrypted external $ getGpgEncParams (c,gc))
(retrieveEncrypted external)
@@ -66,11 +67,11 @@ gen r u c gc = do
repo = r,
gitconfig = gc,
readonly = False,
- globallyAvailable = False,
+ availability = avail,
remotetype = remote
}
where
- externaltype = fromMaybe (error "missing externaltype") $ remoteAnnexExternalType gc
+ externaltype = fromMaybe (error "missing externaltype") (remoteAnnexExternalType gc)
externalSetup :: Maybe UUID -> RemoteConfig -> Annex (RemoteConfig, UUID)
externalSetup mu c = do
@@ -419,3 +420,21 @@ getCost external r gc = go =<< remoteCost' gc
_ -> Nothing
setRemoteCost r c
return c
+
+{- Caches the availability in the git config to avoid needing to start up an
+ - external special remote every time time just to ask it what its
+ - availability is.
+ -
+ - Most remotes do not bother to implement a reply to this request;
+ - globally available is the default.
+ -}
+getAvailability :: External -> Git.Repo -> RemoteGitConfig -> Annex Availability
+getAvailability external r gc = maybe query return (remoteAnnexAvailability gc)
+ where
+ query = do
+ avail <- handleRequest external GETAVAILABILITY Nothing $ \req -> case req of
+ AVAILABILITY avail -> Just $ return avail
+ UNSUPPORTED_REQUEST -> Just $ return GloballyAvailable
+ _ -> Nothing
+ setRemoteAvailability r avail
+ return avail