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:
parent
d3c75c003a
commit
a6ea057f6b
3 changed files with 23 additions and 10 deletions
|
@ -81,7 +81,7 @@ proxySpecialRemote protoversion r ihdl ohdl endv = go
|
||||||
tryNonAsync (Remote.checkPresent r k) >>= \case
|
tryNonAsync (Remote.checkPresent r k) >>= \case
|
||||||
Right True -> sendmessage SUCCESS
|
Right True -> sendmessage SUCCESS
|
||||||
Right False -> sendmessage FAILURE
|
Right False -> sendmessage FAILURE
|
||||||
Left err -> sendmessage (ERROR (show err))
|
Left err -> propagateerror err
|
||||||
go
|
go
|
||||||
Just (LOCKCONTENT _) -> do
|
Just (LOCKCONTENT _) -> do
|
||||||
-- Special remotes do not support locking content.
|
-- Special remotes do not support locking content.
|
||||||
|
@ -119,3 +119,6 @@ proxySpecialRemote protoversion r ihdl ohdl endv = go
|
||||||
|
|
||||||
sendmessage m = liftIO $ atomically $ putTMVar ihdl (Right m)
|
sendmessage m = liftIO $ atomically $ putTMVar ihdl (Right m)
|
||||||
sendbytestring b = liftIO $ atomically $ putTMVar ihdl (Left b)
|
sendbytestring b = liftIO $ atomically $ putTMVar ihdl (Left b)
|
||||||
|
|
||||||
|
propagateerror err = sendmessage $ ERROR $
|
||||||
|
"proxied special remote reports: " ++ show err
|
||||||
|
|
|
@ -353,10 +353,10 @@ sendBypass bypass@(Bypass s)
|
||||||
then net $ sendMessage (BYPASS bypass)
|
then net $ sendMessage (BYPASS bypass)
|
||||||
else return ()
|
else return ()
|
||||||
|
|
||||||
checkPresent :: Key -> Proto Bool
|
checkPresent :: Key -> Proto (Either String Bool)
|
||||||
checkPresent key = do
|
checkPresent key = do
|
||||||
net $ sendMessage (CHECKPRESENT key)
|
net $ sendMessage (CHECKPRESENT key)
|
||||||
checkSuccess
|
checkSuccess'
|
||||||
|
|
||||||
{- Locks content to prevent it from being dropped, while running an action.
|
{- 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
|
return observeFailure
|
||||||
|
|
||||||
checkSuccess :: Proto Bool
|
checkSuccess :: Proto Bool
|
||||||
checkSuccess = do
|
checkSuccess = either (const False) id <$> checkSuccess'
|
||||||
|
|
||||||
|
checkSuccess' :: Proto (Either String Bool)
|
||||||
|
checkSuccess' = do
|
||||||
ack <- net receiveMessage
|
ack <- net receiveMessage
|
||||||
case ack of
|
case ack of
|
||||||
Just SUCCESS -> return True
|
Just SUCCESS -> return (Right True)
|
||||||
Just FAILURE -> return False
|
Just FAILURE -> return (Right False)
|
||||||
|
Just (ERROR err) -> return (Left err)
|
||||||
_ -> do
|
_ -> do
|
||||||
net $ sendMessage (ERROR "expected SUCCESS or FAILURE")
|
net $ sendMessage (ERROR "expected SUCCESS or FAILURE")
|
||||||
return False
|
return (Right False)
|
||||||
|
|
||||||
checkSuccessPlus :: Proto (Maybe [UUID])
|
checkSuccessPlus :: Proto (Maybe [UUID])
|
||||||
checkSuccessPlus =
|
checkSuccessPlus =
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- Helpers for remotes using the git-annex P2P protocol.
|
{- Helpers for remotes using the git-annex P2P protocol.
|
||||||
-
|
-
|
||||||
- Copyright 2016-2021 Joey Hess <id@joeyh.name>
|
- Copyright 2016-2024 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -20,6 +20,7 @@ import Utility.Tuple
|
||||||
import Types.NumCopies
|
import Types.NumCopies
|
||||||
import Annex.Verify
|
import Annex.Verify
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
|
import Utility.SafeOutput
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
||||||
|
@ -74,8 +75,13 @@ remove remoteuuid runner k = runner (P2P.remove k) >>= \case
|
||||||
when (u /= remoteuuid) $
|
when (u /= remoteuuid) $
|
||||||
logChange k u InfoMissing
|
logChange k u InfoMissing
|
||||||
|
|
||||||
checkpresent :: ProtoRunner Bool -> Key -> Annex Bool
|
checkpresent :: ProtoRunner (Either String Bool) -> Key -> Annex Bool
|
||||||
checkpresent runner k = maybe remoteUnavail return =<< runner (P2P.checkPresent k)
|
checkpresent runner k =
|
||||||
|
runner (P2P.checkPresent k)
|
||||||
|
>>= \case
|
||||||
|
Nothing -> remoteUnavail
|
||||||
|
Just (Right b) -> return b
|
||||||
|
Just (Left err) -> giveup (safeOutput err)
|
||||||
|
|
||||||
lock :: WithConn a c -> ProtoConnRunner c -> UUID -> Key -> (VerifiedCopy -> Annex a) -> Annex a
|
lock :: WithConn a c -> ProtoConnRunner c -> UUID -> Key -> (VerifiedCopy -> Annex a) -> Annex a
|
||||||
lock withconn connrunner u k callback = withconn $ \conn -> do
|
lock withconn connrunner u k callback = withconn $ \conn -> do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue