data ProxySelector = ProxySelector
{ proxyCHECKPRESENT :: Key -> Annex (Maybe RemoteSide)
, proxyLOCKCONTENT :: Key -> Annex (Maybe RemoteSide)
- , proxyUNLOCKCONTENT :: Annex (Maybe RemoteSide)
, proxyREMOVE :: Key -> Annex [RemoteSide]
-- ^ remove from all of these remotes
, proxyGETTIMESTAMP :: Annex [RemoteSide]
singleProxySelector r = ProxySelector
{ proxyCHECKPRESENT = const (pure (Just r))
, proxyLOCKCONTENT = const (pure (Just r))
- , proxyUNLOCKCONTENT = pure (Just r)
, proxyREMOVE = const (pure [r])
, proxyGETTIMESTAMP = pure [r]
, proxyGET = const (pure (Just r))
client $ net $ sendMessage FAILURE
LOCKCONTENT k -> proxyLOCKCONTENT (proxySelector proxyparams) k >>= \case
Just remoteside ->
- proxyresponse remoteside requestmessage
- (const requestcomplete)
+ handleLOCKCONTENT remoteside requestmessage
Nothing ->
protoerrhandler requestcomplete $
client $ net $ sendMessage FAILURE
- UNLOCKCONTENT -> proxyUNLOCKCONTENT (proxySelector proxyparams) >>= \case
- Just remoteside ->
- proxynoresponse remoteside requestmessage
- requestcomplete
- Nothing -> requestcomplete ()
REMOVE k -> do
remotesides <- proxyREMOVE (proxySelector proxyparams) k
servermodechecker checkREMOVEServerMode $
FAILURE_PLUS _ -> protoerr
DATA _ -> protoerr
VALIDITY _ -> protoerr
+ UNLOCKCONTENT -> protoerr
-- If the client errors out, give up.
ERROR msg -> giveup $ "client error: " ++ msg
-- Messages that only the server should send.
protoerrhandler (a resp) $
client $ net $ sendMessage resp
- -- Send a message to the remote, that it will not respond to.
- proxynoresponse remoteside message a =
- protoerrhandler a $
- runRemoteSide remoteside $ net $ sendMessage message
-
-- Send a message to the endpoint and get back its response.
getresponse endpoint message handleresp =
protoerrhandler (withresp handleresp) $
to $ net $ sendMessage message
protoerr = do
- _ <- client $ net $ sendMessage (ERROR "protocol error X")
- giveup "protocol error M"
+ _ <- client $ net $ sendMessage (ERROR "protocol error")
+ giveup "protocol error"
+
+ handleLOCKCONTENT remoteside msg =
+ proxyresponse remoteside msg $ \r () -> case r of
+ SUCCESS -> relayonemessage client
+ (runRemoteSide remoteside)
+ (const requestcomplete)
+ FAILURE -> requestcomplete ()
+ _ -> requestcomplete ()
-- When there is a single remote, reply with its timestamp,
-- to avoid needing timestamp translation.
## work notes
-* This against a http proxied remote leads to a protocol error:
-
- git-annex move foo --to origin-c
- git-annex get foo --from origin-c
-
- ERROR expected UNLOCKCONTENT
-
- May need to run the commands a few times before it happens.
-
- I think it's because proxyRequest treats LOCKCONTENT as a single
- command+reponse, with UNLOCKCONTENT separately. So it's possible for
- there to be two different connections to the proxied remote,
- with LOCKCONTENT being sent to one, and UNLOCKCONTENT to the other one.
-
* test http server proxying with special remotes
* Make http server support clusters.