starting support for remote.name.annexUrl set to annex+http

In this case, Remote.Git should not use that url for all access to
the repository. It will only be used for annex operations, which isn't
done yet.
This commit is contained in:
Joey Hess 2024-07-23 09:12:21 -04:00
parent fdb888a56a
commit 5c39652235
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 30 additions and 8 deletions

View file

@ -13,6 +13,7 @@ module Command.P2PHttp where
import Command import Command
import P2P.Http import P2P.Http
import P2P.Http.Url
import qualified P2P.Protocol as P2P import qualified P2P.Protocol as P2P
import Annex.Url import Annex.Url
import Utility.Env import Utility.Env
@ -79,7 +80,9 @@ seek o = getAnnexWorkerPool $ \workerpool -> do
mkGetServerMode authenv o mkGetServerMode authenv o
Warp.run (fromIntegral port) (p2pHttpApp st) Warp.run (fromIntegral port) (p2pHttpApp st)
where where
port = fromMaybe (fromIntegral defaultHttpProtocolPort) (portOption o) port = fromMaybe
(fromIntegral defaultP2PHttpProtocolPort)
(portOption o)
mkGetServerMode :: M.Map Auth P2P.ServerMode -> Options -> GetServerMode mkGetServerMode :: M.Map Auth P2P.ServerMode -> Options -> GetServerMode
mkGetServerMode _ o _ Nothing mkGetServerMode _ o _ Nothing

View file

@ -43,9 +43,6 @@ import Control.Concurrent.Async
import Control.Concurrent import Control.Concurrent
import System.IO.Unsafe import System.IO.Unsafe
defaultHttpProtocolPort :: Int
defaultHttpProtocolPort = 9417 -- Git protocol is 9418
type P2PHttpAPI type P2PHttpAPI
= "git-annex" :> SU :> PV3 :> "key" :> GetAPI = "git-annex" :> SU :> PV3 :> "key" :> GetAPI
:<|> "git-annex" :> SU :> PV2 :> "key" :> GetAPI :<|> "git-annex" :> SU :> PV2 :> "key" :> GetAPI

18
P2P/Http/Url.hs Normal file
View file

@ -0,0 +1,18 @@
{- P2P protocol over HTTP, urls
-
- Copyright 2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module P2P.Http.Url where
import Data.List
defaultP2PHttpProtocolPort :: Int
defaultP2PHttpProtocolPort = 9417 -- Git protocol is 9418
isP2PHttpProtocolUrl :: String -> Bool
isP2PHttpProtocolUrl s =
"annex+http://" `isPrefixOf` s ||
"annex+https://" `isPrefixOf` s

View file

@ -58,6 +58,7 @@ import qualified Remote.GitLFS
import qualified Remote.P2P import qualified Remote.P2P
import qualified Remote.Helper.P2P as P2PHelper import qualified Remote.Helper.P2P as P2PHelper
import P2P.Address import P2P.Address
import P2P.Http.Url
import Annex.Path import Annex.Path
import Creds import Creds
import Types.NumCopies import Types.NumCopies
@ -107,10 +108,12 @@ list autoinit = do
tweakurl c r = do tweakurl c r = do
let n = fromJust $ Git.remoteName r let n = fromJust $ Git.remoteName r
case M.lookup (annexurl r) c of case M.lookup (annexurl r) c of
Nothing -> return r Just url | not (isP2PHttpProtocolUrl (Git.fromConfigValue url)) ->
Just url -> inRepo $ \g -> inRepo $ \g -> Git.Construct.remoteNamed n $
Git.Construct.remoteNamed n $ Git.Construct.fromRemoteLocation
Git.Construct.fromRemoteLocation (Git.fromConfigValue url) False g (Git.fromConfigValue url)
False g
_ -> return r
isGitRemoteAnnex :: Git.Repo -> Bool isGitRemoteAnnex :: Git.Repo -> Bool
isGitRemoteAnnex r = "annex::" `isPrefixOf` Git.repoLocation r isGitRemoteAnnex r = "annex::" `isPrefixOf` Git.repoLocation r

View file

@ -895,6 +895,7 @@ Executable git-annex
P2P.Address P2P.Address
P2P.Annex P2P.Annex
P2P.Auth P2P.Auth
P2P.Http.Url
P2P.IO P2P.IO
P2P.Protocol P2P.Protocol
P2P.Proxy P2P.Proxy