remove uuid from annex+http urls

Not needed it turns out.
This commit is contained in:
Joey Hess 2024-07-28 20:29:42 -04:00
parent bc9cc79e85
commit cd89f91aa5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 14 additions and 58 deletions

View file

@ -138,7 +138,7 @@ p2pHttpClientVersions allowedversion rmt fallback clientaction =
credentialbaseurl = case p2pHttpUrlString <$> remoteAnnexP2PHttpUrl (gitconfig rmt) of
Nothing -> error "internal"
Just url -> p2pHttpUrlWithoutUUID url
Just url -> url
credauth cred = do
ba <- Git.credentialBasicAuth cred

View file

@ -32,7 +32,6 @@ isP2PHttpProtocolUrl s =
data P2PHttpUrl = P2PHttpUrl
{ p2pHttpUrlString :: String
, p2pHttpUUID :: Maybe UUID
#ifdef WITH_SERVANT
, p2pHttpBaseUrl :: BaseUrl
#endif
@ -50,29 +49,19 @@ parseP2PHttpUrl us
"https:" -> mkbaseurl Https u
_ -> Nothing
#else
Just $ P2PHttpUrl us (extractuuid u)
Just $ P2PHttpUrl us
#endif
| otherwise = Nothing
where
prefixlen = length "annex+"
extractuuid u = do
p <- lastMaybe $ P.splitDirectories (uriPath u)
-- While git-annex generally allows a UUID that is not
-- well formed, here it's important to make sure that the
-- url a user provided really ends with a UUID, so check
-- that it's well formed.
case UUID.fromString p of
Nothing -> Nothing
Just _ -> return (UUID (encodeBS p))
#ifdef WITH_SERVANT
mkbaseurl s u = do
auth <- uriAuthority u
port <- if null (uriPort auth)
then Just defaultP2PHttpProtocolPort
else readMaybe (dropWhile (== ':') (uriPort auth))
return $ P2PHttpUrl us (extractuuid u) $ BaseUrl
return $ P2PHttpUrl us $ BaseUrl
{ baseUrlScheme = s
, baseUrlHost = uriRegName auth
, baseUrlPath = basepath u
@ -84,14 +73,11 @@ parseP2PHttpUrl us
-- it from the url that the user provided. However, it may not be
-- present, eg if some other server is speaking the git-annex
-- protocol. The UUID is also removed from the end of the url.
basepath u = case drop 1 $ reverse $ P.splitDirectories (uriPath u) of
basepath u = case reverse $ P.splitDirectories (uriPath u) of
("git-annex":"/":rest) -> P.joinPath (reverse rest)
rest -> P.joinPath (reverse rest)
#endif
p2pHttpUrlWithoutUUID :: String -> String
p2pHttpUrlWithoutUUID = reverse . dropWhile (/= '/') . reverse
unavailableP2PHttpUrl :: P2PHttpUrl -> P2PHttpUrl
unavailableP2PHttpUrl p = p
#ifdef WITH_SERVANT