fix display when proxied GET yields ERROR
The error message is not displayed to the use, but this mirrors the behavior when a regular get from a special remote fails. At least now there is not a protocol error.
This commit is contained in:
parent
dce3848ad8
commit
fa5e7463eb
5 changed files with 21 additions and 16 deletions
|
@ -114,7 +114,7 @@ proxySpecialRemote protoversion r ihdl ohdl owaitv endv = go
|
||||||
liftIO $ sendmessage $
|
liftIO $ sendmessage $
|
||||||
ERROR "NOTIFYCHANGE unsupported for a special remote"
|
ERROR "NOTIFYCHANGE unsupported for a special remote"
|
||||||
go
|
go
|
||||||
Just _ -> giveup "protocol error"
|
Just _ -> giveup "protocol error M"
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
||||||
getnextmessageorend =
|
getnextmessageorend =
|
||||||
|
@ -167,9 +167,9 @@ proxySpecialRemote protoversion r ihdl ohdl owaitv endv = go
|
||||||
store
|
store
|
||||||
Just (VALIDITY Invalid) ->
|
Just (VALIDITY Invalid) ->
|
||||||
return ()
|
return ()
|
||||||
_ -> giveup "protocol error"
|
_ -> giveup "protocol error N"
|
||||||
else store
|
else store
|
||||||
_ -> giveup "protocol error"
|
_ -> giveup "protocol error O"
|
||||||
|
|
||||||
proxyget offset af k = withproxytmpfile k $ \tmpfile -> do
|
proxyget offset af k = withproxytmpfile k $ \tmpfile -> do
|
||||||
-- Don't verify the content from the remote,
|
-- Don't verify the content from the remote,
|
||||||
|
@ -206,6 +206,6 @@ proxySpecialRemote protoversion r ihdl ohdl owaitv endv = go
|
||||||
receivemessage >>= \case
|
receivemessage >>= \case
|
||||||
Just SUCCESS -> return ()
|
Just SUCCESS -> return ()
|
||||||
Just FAILURE -> return ()
|
Just FAILURE -> return ()
|
||||||
Just _ -> giveup "protocol error"
|
Just _ -> giveup "protocol error P"
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ runNet runst conn runner f = case f of
|
||||||
Right () -> runner next
|
Right () -> runner next
|
||||||
ReceiveMessage next ->
|
ReceiveMessage next ->
|
||||||
let protoerr = return $ Left $
|
let protoerr = return $ Left $
|
||||||
ProtoFailureMessage "protocol error"
|
ProtoFailureMessage "protocol error 1"
|
||||||
gotmessage m = do
|
gotmessage m = do
|
||||||
liftIO $ debugMessage conn "P2P <" m
|
liftIO $ debugMessage conn "P2P <" m
|
||||||
runner (next (Just m))
|
runner (next (Just m))
|
||||||
|
@ -263,7 +263,7 @@ runNet runst conn runner f = case f of
|
||||||
liftIO (atomically (takeTMVar mv)) >>= \case
|
liftIO (atomically (takeTMVar mv)) >>= \case
|
||||||
Left b -> runner (next b)
|
Left b -> runner (next b)
|
||||||
Right _ -> return $ Left $
|
Right _ -> return $ Left $
|
||||||
ProtoFailureMessage "protocol error"
|
ProtoFailureMessage "protocol error 2"
|
||||||
CheckAuthToken _u t next -> do
|
CheckAuthToken _u t next -> do
|
||||||
let authed = connCheckAuth conn t
|
let authed = connCheckAuth conn t
|
||||||
runner (next authed)
|
runner (next authed)
|
||||||
|
|
|
@ -623,6 +623,8 @@ receiveContent mm p sizer storer mkmsg = do
|
||||||
validitycheck
|
validitycheck
|
||||||
sendSuccess (observeBool v)
|
sendSuccess (observeBool v)
|
||||||
return v
|
return v
|
||||||
|
Just (ERROR _err) ->
|
||||||
|
return observeFailure
|
||||||
_ -> do
|
_ -> do
|
||||||
net $ sendMessage (ERROR "expected DATA")
|
net $ sendMessage (ERROR "expected DATA")
|
||||||
return observeFailure
|
return observeFailure
|
||||||
|
|
18
P2P/Proxy.hs
18
P2P/Proxy.hs
|
@ -315,8 +315,8 @@ proxy proxydone proxymethods servermode (ClientSide clientrunst clientconn) remo
|
||||||
to $ net $ sendMessage message
|
to $ net $ sendMessage message
|
||||||
|
|
||||||
protoerr = do
|
protoerr = do
|
||||||
_ <- client $ net $ sendMessage (ERROR "protocol error")
|
_ <- client $ net $ sendMessage (ERROR "protocol error X")
|
||||||
giveup "protocol error"
|
giveup "protocol error M"
|
||||||
|
|
||||||
handleREMOVE [] _ _ =
|
handleREMOVE [] _ _ =
|
||||||
-- When no places are provided to remove from,
|
-- When no places are provided to remove from,
|
||||||
|
@ -357,7 +357,10 @@ proxy proxydone proxymethods servermode (ClientSide clientrunst clientconn) remo
|
||||||
else FAILURE_PLUS us
|
else FAILURE_PLUS us
|
||||||
|
|
||||||
handleGET remoteside message = getresponse (runRemoteSide remoteside) message $
|
handleGET remoteside message = getresponse (runRemoteSide remoteside) message $
|
||||||
withDATA (relayGET remoteside)
|
withDATA (relayGET remoteside) $ \case
|
||||||
|
ERROR err -> protoerrhandler proxynextclientmessage $
|
||||||
|
client $ net $ sendMessage (ERROR err)
|
||||||
|
_ -> protoerr
|
||||||
|
|
||||||
handlePUT (remoteside:[]) k message
|
handlePUT (remoteside:[]) k message
|
||||||
| Remote.uuid (remote remoteside) == remoteuuid =
|
| Remote.uuid (remote remoteside) == remoteuuid =
|
||||||
|
@ -368,7 +371,9 @@ proxy proxydone proxymethods servermode (ClientSide clientrunst clientconn) remo
|
||||||
client $ net $ sendMessage resp
|
client $ net $ sendMessage resp
|
||||||
PUT_FROM _ ->
|
PUT_FROM _ ->
|
||||||
getresponse client resp $
|
getresponse client resp $
|
||||||
withDATA (relayPUT remoteside k)
|
withDATA
|
||||||
|
(relayPUT remoteside k)
|
||||||
|
(const protoerr)
|
||||||
_ -> protoerr
|
_ -> protoerr
|
||||||
handlePUT [] _ _ =
|
handlePUT [] _ _ =
|
||||||
protoerrhandler proxynextclientmessage $
|
protoerrhandler proxynextclientmessage $
|
||||||
|
@ -376,8 +381,8 @@ proxy proxydone proxymethods servermode (ClientSide clientrunst clientconn) remo
|
||||||
handlePUT remotesides k message =
|
handlePUT remotesides k message =
|
||||||
handlePutMulti remotesides k message
|
handlePutMulti remotesides k message
|
||||||
|
|
||||||
withDATA a message@(DATA len) = a len message
|
withDATA a _ message@(DATA len) = a len message
|
||||||
withDATA _ _ = protoerr
|
withDATA _ a message = a message
|
||||||
|
|
||||||
relayGET remoteside len = relayDATAStart client $
|
relayGET remoteside len = relayDATAStart client $
|
||||||
relayDATACore len (runRemoteSide remoteside) client $
|
relayDATACore len (runRemoteSide remoteside) client $
|
||||||
|
@ -439,6 +444,7 @@ proxy proxydone proxymethods servermode (ClientSide clientrunst clientconn) remo
|
||||||
let minoffset = minimum (map snd l')
|
let minoffset = minimum (map snd l')
|
||||||
getresponse client (PUT_FROM (Offset minoffset)) $
|
getresponse client (PUT_FROM (Offset minoffset)) $
|
||||||
withDATA (relayPUTMulti minoffset l' k)
|
withDATA (relayPUTMulti minoffset l' k)
|
||||||
|
(const protoerr)
|
||||||
|
|
||||||
relayPUTMulti minoffset remotes k (Len datalen) _ = do
|
relayPUTMulti minoffset remotes k (Len datalen) _ = do
|
||||||
let totallen = datalen + minoffset
|
let totallen = datalen + minoffset
|
||||||
|
|
|
@ -31,9 +31,6 @@ For June's work on [[design/passthrough_proxy]], remaining todos:
|
||||||
needs some disk. And it could minimize to eg, the last 2 or so.
|
needs some disk. And it could minimize to eg, the last 2 or so.
|
||||||
The design doc has some more thoughts about this.
|
The design doc has some more thoughts about this.
|
||||||
|
|
||||||
* If GET from a proxied special remote sends an ERROR with a message
|
|
||||||
from the special remote, currently the user sees "protocol error".
|
|
||||||
|
|
||||||
* Streaming download from proxied special remotes. See design.
|
* Streaming download from proxied special remotes. See design.
|
||||||
|
|
||||||
* Check annex.diskreserve when proxying for special remotes.
|
* Check annex.diskreserve when proxying for special remotes.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue