clean P2P protocol shutdown on EOF try 2

Same goal as b18fb1e343 but without
breaking backwards compatability. Just return IO exceptions when running
the P2P protocol, so that git-annex-shell can detect eof and avoid the
ugly message.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2018-09-25 16:49:59 -04:00
parent 80defa62c6
commit 6134431254
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
8 changed files with 70 additions and 45 deletions

View file

@ -32,8 +32,9 @@ run (_remotename:address:[]) = forever $
| otherwise = parseAddressPort address
go service = do
ready
either giveup exitWith
=<< connectService onionaddress onionport service
connectService onionaddress onionport service >>= \case
Right exitcode -> exitWith exitcode
Left e -> giveup $ describeProtoFailure e
ready = do
putStrLn ""
hFlush stdout
@ -48,7 +49,7 @@ parseAddressPort s =
Nothing -> giveup "onion address must include port number"
Just p -> (OnionAddress a, p)
connectService :: OnionAddress -> OnionPort -> Service -> IO (Either String ExitCode)
connectService :: OnionAddress -> OnionPort -> Service -> IO (Either ProtoFailure ExitCode)
connectService address port service = do
state <- Annex.new =<< Git.CurrentRepo.get
Annex.eval state $ do