aboutsummaryrefslogtreecommitdiff
path: root/Remote/External.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2014-12-11 15:32:42 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2014-12-11 15:33:42 -0400
commitc4ff79b1a460a3526c6772ab754cb34e5f7f3dd2 (patch)
tree80bea71f1d453348cb2d0a92ce10e463aab9259e /Remote/External.hs
parent4e88f7e9af6a776347649047f2473e470a729ed9 (diff)
Expand checkurl to support recommended filename, and multi-file-urls
This commit was sponsored by an anonymous bitcoiner.
Diffstat (limited to 'Remote/External.hs')
-rw-r--r--Remote/External.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Remote/External.hs b/Remote/External.hs
index 62671755c..c5330f7ea 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -12,6 +12,7 @@ import qualified Annex
import Common.Annex
import Types.Remote
import Types.CleanupActions
+import Types.UrlContents
import qualified Git
import Config
import Remote.Helper.Special
@@ -71,7 +72,7 @@ gen r u c gc = do
gc { remoteAnnexExternalType = Just "!dne!" },
getInfo = return [("externaltype", externaltype)],
claimUrl = Just (claimurl external),
- checkUrl = checkurl external
+ checkUrl = Just (checkurl external)
}
where
externaltype = fromMaybe (error "missing externaltype") (remoteAnnexExternalType gc)
@@ -429,11 +430,14 @@ claimurl external url =
UNSUPPORTED_REQUEST -> Just $ return False
_ -> Nothing
-checkurl :: External -> URLString -> Annex (Maybe Integer)
+checkurl :: External -> URLString -> Annex UrlContents
checkurl external url =
handleRequest external (CHECKURL url) Nothing $ \req -> case req of
- CHECKURL_SIZE sz -> Just $ return $ Just sz
- CHECKURL_SIZEUNKNOWN -> Just $ return Nothing
+ CHECKURL_CONTENTS sz f -> Just $ return $ UrlContents sz
+ (if null f then id else const f)
+ CHECKURL_MULTI l -> Just $ return $ UrlNested $ map mknested l
CHECKURL_FAILURE errmsg -> Just $ error errmsg
UNSUPPORTED_REQUEST -> error "CHECKURL not implemented by external special remote"
_ -> Nothing
+ where
+ mknested (url', sz, f) = (url', UrlContents sz (const f))