fix handling of ERROR in response to CHECKPRESENT

That error is now rethrown on the client, so it will be displayed.

For example:

$ git-annex fsck x --fast --from AMS-dir
fsck x (special remote reports: directory /home/joey/tmp/bench2/dir is not accessible) failed

No protocol version check is needed. Because in order to talk to a
proxied special remote, the client has to be running the upcoming
git-annex release. Which has this fix in it.
This commit is contained in:
Joey Hess 2024-06-28 13:42:25 -04:00
parent d3c75c003a
commit a6ea057f6b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 23 additions and 10 deletions

View file

@ -353,10 +353,10 @@ sendBypass bypass@(Bypass s)
then net $ sendMessage (BYPASS bypass)
else return ()
checkPresent :: Key -> Proto Bool
checkPresent :: Key -> Proto (Either String Bool)
checkPresent key = do
net $ sendMessage (CHECKPRESENT key)
checkSuccess
checkSuccess'
{- Locks content to prevent it from being dropped, while running an action.
-
@ -628,14 +628,18 @@ receiveContent mm p sizer storer mkmsg = do
return observeFailure
checkSuccess :: Proto Bool
checkSuccess = do
checkSuccess = either (const False) id <$> checkSuccess'
checkSuccess' :: Proto (Either String Bool)
checkSuccess' = do
ack <- net receiveMessage
case ack of
Just SUCCESS -> return True
Just FAILURE -> return False
Just SUCCESS -> return (Right True)
Just FAILURE -> return (Right False)
Just (ERROR err) -> return (Left err)
_ -> do
net $ sendMessage (ERROR "expected SUCCESS or FAILURE")
return False
return (Right False)
checkSuccessPlus :: Proto (Maybe [UUID])
checkSuccessPlus =