Added WHEREIS to external special remote protocol.
This commit is contained in:
parent
c6bea20f3d
commit
6bc46e384e
5 changed files with 56 additions and 5 deletions
|
@ -60,7 +60,7 @@ gen r u c gc = do
|
|||
, removeKey = removeKeyDummy
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
, whereisKey = Just $ whereis external
|
||||
, remoteFsck = Nothing
|
||||
, repairRepo = Nothing
|
||||
, config = c
|
||||
|
@ -144,6 +144,13 @@ checkKey external k = either error id <$> go
|
|||
| k' == k -> Just $ return $ Left errmsg
|
||||
_ -> Nothing
|
||||
|
||||
whereis :: External -> Key -> Annex [String]
|
||||
whereis external k = handleRequest external (WHEREIS k) Nothing $ \resp -> case resp of
|
||||
WHEREIS_SUCCESS s -> Just $ return [s]
|
||||
WHEREIS_FAILURE -> Just $ return []
|
||||
UNSUPPORTED_REQUEST -> Just $ return []
|
||||
_ -> Nothing
|
||||
|
||||
safely :: Annex Bool -> Annex Bool
|
||||
safely a = go =<< tryNonAsync a
|
||||
where
|
||||
|
|
6
Remote/External/Types.hs
vendored
6
Remote/External/Types.hs
vendored
|
@ -97,6 +97,7 @@ data Request
|
|||
| TRANSFER Direction Key FilePath
|
||||
| CHECKPRESENT Key
|
||||
| REMOVE Key
|
||||
| WHEREIS Key
|
||||
deriving (Show)
|
||||
|
||||
-- Does PREPARE need to have been sent before this request?
|
||||
|
@ -120,6 +121,7 @@ instance Proto.Sendable Request where
|
|||
]
|
||||
formatMessage (CHECKPRESENT key) = [ "CHECKPRESENT", Proto.serialize key ]
|
||||
formatMessage (REMOVE key) = [ "REMOVE", Proto.serialize key ]
|
||||
formatMessage (WHEREIS key) = [ "WHEREIS", Proto.serialize key ]
|
||||
|
||||
-- Responses the external remote can make to requests.
|
||||
data Response
|
||||
|
@ -141,6 +143,8 @@ data Response
|
|||
| CHECKURL_CONTENTS Size FilePath
|
||||
| CHECKURL_MULTI [(URLString, Size, FilePath)]
|
||||
| CHECKURL_FAILURE ErrorMsg
|
||||
| WHEREIS_SUCCESS String
|
||||
| WHEREIS_FAILURE
|
||||
| UNSUPPORTED_REQUEST
|
||||
deriving (Show)
|
||||
|
||||
|
@ -163,6 +167,8 @@ instance Proto.Receivable Response where
|
|||
parseCommand "CHECKURL-CONTENTS" = Proto.parse2 CHECKURL_CONTENTS
|
||||
parseCommand "CHECKURL-MULTI" = Proto.parse1 CHECKURL_MULTI
|
||||
parseCommand "CHECKURL-FAILURE" = Proto.parse1 CHECKURL_FAILURE
|
||||
parseCommand "WHEREIS-SUCCESS" = Just . WHEREIS_SUCCESS
|
||||
parseCommand "WHEREIS-FAILURE" = Proto.parse0 WHEREIS_FAILURE
|
||||
parseCommand "UNSUPPORTED-REQUEST" = Proto.parse0 UNSUPPORTED_REQUEST
|
||||
parseCommand _ = Proto.parseFail
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue