added retrieveKeyFileInOrder and ORDERED to external special remote protocol

I anticipate lots of external special remote programs will neglect
implementing this. Still, it's the right thing to do to assume that some
of them may write files out of order. Probably most external special
remotes will not be used with a proxy. When someone is using one with a
proxy, they can always get it fixed to send ORDERED.
This commit is contained in:
Joey Hess 2024-10-15 15:35:09 -04:00
parent f920d90781
commit d9b4bf4224
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
28 changed files with 80 additions and 13 deletions

View file

@ -68,7 +68,7 @@ gen rt externalprogram r u rc gc rs
| externalprogram' == ExternalType "readonly" = do
c <- parsedRemoteConfig remote rc
cst <- remoteCost gc c expensiveRemoteCost
let rmt = mk c cst (pure GloballyAvailable)
let rmt = mk c cst (pure True) (pure GloballyAvailable)
Nothing
(externalInfo externalprogram')
Nothing
@ -105,7 +105,9 @@ gen rt externalprogram r u rc gc rs
let cheapexportsupported = if exportsupported
then exportIsSupported
else exportUnsupported
let rmt = mk c cst (getAvailability external)
let rmt = mk c cst
(getOrdered external)
(getAvailability external)
(Just (whereisKeyM external))
(getInfoM external)
(Just (claimUrlM external))
@ -119,13 +121,14 @@ gen rt externalprogram r u rc gc rs
(checkPresentM external)
rmt
where
mk c cst avail towhereis togetinfo toclaimurl tocheckurl exportactions cheapexportsupported =
mk c cst ordered avail towhereis togetinfo toclaimurl tocheckurl exportactions cheapexportsupported =
Remote
{ uuid = u
, cost = cst
, name = Git.repoDescribe r
, storeKey = storeKeyDummy
, retrieveKeyFile = retrieveKeyFileDummy
, retrieveKeyFileInOrder = ordered
, retrieveKeyFileCheap = Nothing
-- External special remotes use many http libraries
-- and have no protection against redirects to
@ -801,6 +804,14 @@ getAvailability external = catchNonAsync query (const (pure defavail))
_ -> Nothing
defavail = GloballyAvailable
getOrdered :: External -> Annex Bool
getOrdered external = catchNonAsync query (const (pure False))
where
query = handleRequest external GETORDERED Nothing $ \req -> case req of
ORDERED -> result True
UNORDERED -> result False
_ -> result False
claimUrlM :: External -> URLString -> Annex Bool
claimUrlM external url =
handleRequest external (CLAIMURL url) Nothing $ \req -> case req of