+git-annex (10.20250631) UNRELEASED; urgency=medium
+
+ * p2phttp: Scan multilevel directories with --directory.
+
+ -- Joey Hess <id@joeyh.name> Mon, 07 Jul 2025 15:59:42 -0400
+
git-annex (10.20250630) upstream; urgency=medium
* Work around git 2.50 bug that caused it to crash when there is a merge
{- git-annex command
-
- - Copyright 2024 Joey Hess <id@joeyh.name>
+ - Copyright 2024-2025 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
import qualified Git.Construct
import qualified Annex
import Types.Concurrency
+import qualified Utility.RawFilePath as R
import Servant
import qualified Network.Wai.Handler.Warp as Warp
import qualified Network.Wai.Handler.WarpTLS as Warp
import Network.Socket (PortNumber)
+import System.PosixCompat.Files (isSymbolicLink)
import qualified Data.Map as M
import Data.String
import Control.Concurrent.STM
findRepos o = do
files <- concat
<$> mapM (dirContents . toOsPath) (directoryOption o)
- map Git.Construct.newFrom . catMaybes
- <$> mapM Git.Construct.checkForRepo files
-
+ concat <$> mapM go files
+ where
+ go f = Git.Construct.checkForRepo f >>= \case
+ Just loc -> return [Git.Construct.newFrom loc]
+ Nothing ->
+ -- Avoid following symlinks, both to avoid
+ -- cycles and in case there is an unexpected
+ -- symlink to some other directory we are not
+ -- supposed to serve.
+ ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
+ ( return []
+ -- Ignore any errors getting the contents of a
+ -- subdirectory.
+ , catchNonAsync
+ (concat <$> (mapM go =<< dirContents f))
+ (const (return []))
+ )
* `--directory=path`
- Serve each git-annex repository found in immediate
- subdirectories of a directory.
+ Serve each git-annex repository found in subdirectories of the directory.
+ For example, `--directory=/foo` will find git-annex repositories
+ in `/foo/bar`, `/foo/user/bar`, and so on. Note that a git-annex
+ repository located within another git-annex repository will not be found.
This option can be provided more than once to serve several directories
full of git-annex repositories.