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 credentialbaseurl = case p2pHttpUrlString <$> remoteAnnexP2PHttpUrl (gitconfig rmt) of
Nothing -> error "internal" Nothing -> error "internal"
Just url -> p2pHttpUrlWithoutUUID url Just url -> url
credauth cred = do credauth cred = do
ba <- Git.credentialBasicAuth cred ba <- Git.credentialBasicAuth cred

View file

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

View file

@ -169,10 +169,6 @@ enableRemote Nothing _ = giveup "unable to enable git remote with no specified u
- done each time git-annex is run in a way that uses remotes, unless - done each time git-annex is run in a way that uses remotes, unless
- annex-checkuuid is false. - annex-checkuuid is false.
- -
- An annex+http remote's UUID is part of the url,
- so the config does not have to be read, but it is verified that
- it matches the cached UUID.
-
- The config of other URL remotes is only read when there is no - The config of other URL remotes is only read when there is no
- cached UUID value. - cached UUID value.
-} -}
@ -181,27 +177,12 @@ configRead autoinit r = do
gc <- Annex.getRemoteGitConfig r gc <- Annex.getRemoteGitConfig r
hasuuid <- (/= NoUUID) <$> getRepoUUID r hasuuid <- (/= NoUUID) <$> getRepoUUID r
annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc) annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc)
c <- fromRepo Git.config case (repoCheap r, annexignore, hasuuid) of
case (repoCheap r, annexignore, hasuuid, p2pHttpUUID =<< parseP2PHttpUrl =<< getAnnexUrl r c) of (_, True, _) -> return r
(_, True, _, _) -> return r (True, _, _)
(True, _, _, _)
| remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r hasuuid | remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r hasuuid
| otherwise -> return r | otherwise -> return r
(_, _, _, Just p2phttpuuid) -> getRepoUUID r >>= \case (False, _, False) -> configSpecialGitRemotes r >>= \case
u@(UUID {})
| u == p2phttpuuid -> return r
| otherwise -> do
warning $ UnquotedString $ unwords
[ "Repository", Git.repoDescribe r
, "has different UUIDS in"
, Git.fromConfigKey (annexUrlConfigKey r)
, "and"
, Git.fromConfigKey (configRepoUUID r)
]
return r
NoUUID -> storeUpdatedRemote $
liftIO $ setUUID r p2phttpuuid
(False, _, False, _) -> configSpecialGitRemotes r >>= \case
Nothing -> tryGitConfigRead autoinit r False Nothing -> tryGitConfigRead autoinit r False
Just r' -> return r' Just r' -> return r'
_ -> return r _ -> return r
@ -960,7 +941,6 @@ listProxied proxies rs = concat <$> mapM go rs
annexconfigadjuster clusters r' = annexconfigadjuster clusters r' =
let c = adduuid (configRepoUUID renamedr) $ let c = adduuid (configRepoUUID renamedr) $
addurl $ addurl $
addp2phttpurl $
addproxiedby $ addproxiedby $
adjustclusternode clusters $ adjustclusternode clusters $
inheritconfigs $ Git.fullconfig r' inheritconfigs $ Git.fullconfig r'
@ -975,13 +955,6 @@ listProxied proxies rs = concat <$> mapM go rs
addurl = M.insert (mkRemoteConfigKey renamedr (remoteGitConfigKey UrlField)) addurl = M.insert (mkRemoteConfigKey renamedr (remoteGitConfigKey UrlField))
[Git.ConfigValue $ encodeBS $ Git.repoLocation r] [Git.ConfigValue $ encodeBS $ Git.repoLocation r]
addp2phttpurl = case remoteAnnexP2PHttpUrl gc of
Just u -> addremoteannexfield AnnexUrlField
[Git.ConfigValue $ encodeBS $
p2pHttpUrlWithoutUUID (p2pHttpUrlString u)
++ fromUUID (proxyRemoteUUID p)]
Nothing -> id
addproxiedby = case remoteAnnexUUID gc of addproxiedby = case remoteAnnexUUID gc of
Just u -> addremoteannexfield ProxiedByField Just u -> addremoteannexfield ProxiedByField
[Git.ConfigValue $ fromUUID u] [Git.ConfigValue $ fromUUID u]

View file

@ -651,7 +651,7 @@ remoteGitConfigField = \case
ClusterNodeField -> uninherited True "cluster-node" ClusterNodeField -> uninherited True "cluster-node"
ClusterGatewayField -> uninherited True "cluster-gateway" ClusterGatewayField -> uninherited True "cluster-gateway"
UrlField -> uninherited False "url" UrlField -> uninherited False "url"
AnnexUrlField -> uninherited False "annexurl" AnnexUrlField -> inherited False "annexurl"
ShellField -> inherited True "shell" ShellField -> inherited True "shell"
SshOptionsField -> inherited True "ssh-options" SshOptionsField -> inherited True "ssh-options"
RsyncOptionsField -> inherited True "rsync-options" RsyncOptionsField -> inherited True "rsync-options"

View file

@ -10,9 +10,7 @@ connection (mostly). This is a translation of that protocol to HTTP.
To indicate that an url uses this protocol, use To indicate that an url uses this protocol, use
`annex+http` or `annex+https` as the url scheme. Such an url uses `annex+http` or `annex+https` as the url scheme. Such an url uses
port 9417 by default, although another port can be specified. port 9417 by default, although another port can be specified.
The last part of the path of such an url is always the repository uuid. For example, "annex+http://example.com/git-annex/"
For example, `annex+http://example.com/git-annex/$uuid` or
`annex+http://example.com:80/git-annex/$uuid`
## base64 encoding of keys, uuids, and filenames ## base64 encoding of keys, uuids, and filenames

View file

@ -17,7 +17,7 @@ API.
Typically a remote will have `remote.name.url` set to a http url Typically a remote will have `remote.name.url` set to a http url
as usual, and `remote.name.annexUrl` set to an annex+http url such as as usual, and `remote.name.annexUrl` set to an annex+http url such as
`annex+http://example.com/git-annex/$uuid`. The annex+http url is "annex+http://example.com/git-annex/". The annex+http url is
served by this server, and uses port 9417 by default. served by this server, and uses port 9417 by default.
As well as serving the git-annex HTTP API, this server provides a As well as serving the git-annex HTTP API, this server provides a

View file

@ -26,15 +26,14 @@ that git will use, and also have `remote.name.annexUrl` set to the url
that git-annex will use to talk to `git-annex p2phttp`. That url that git-annex will use to talk to `git-annex p2phttp`. That url
looks like this: looks like this:
annex+http://example.com/git-annex/bbdac17e-6633-4b27-8f7b-fb447d5bae7c annex+http://example.com/git-annex/
The "annex+http" (or "annex+https") indicates that it's a git-annex API The "annex+http" (or "annex+https") indicates that it's a git-annex API
url, which defaults to being on port 9417 unless a different port is set. url, which defaults to being on port 9417 unless a different port is set.
And the last part of the url is the annex.uuid of the repository.
It would be annoying if every user who cloned your repository It would be annoying if every user who cloned your repository
had to set `remote.name.annexUrl` manually. So there's a way to automate it. had to set `remote.name.annexUrl` manually. So there's a way to automate it.
In the git config file of the repository, set `annex.url` to the "annex+http" In the git config file of the repository, set `annex.url` to the "annex+http"
(or "annex+https") url. The first time it uses a http remote, git-annex (or "annex+https") url. The first time it uses a http remote, git-annex
downloads the git config file, and sets `remote.name.annexUrl` to the value downloads its git config file, and sets `remote.name.annexUrl` to the value
of annex.url. of the remote's `annex.url`.