From 4cfe17a9e866bda85825237cc655a685d64cc0c3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Aug 2022 13:18:15 -0400 Subject: [PATCH] use a subdirectory of annex.dbdir This allows annex.dbdir to be set globally or always set to the same value when needed. Each repository uses a subdirectory of it. Sponsored-by: Dartmouth College's Datalad project --- Annex/Perms.hs | 2 +- Database/Init.hs | 2 +- Types/GitConfig.hs | 4 +++- .../comment_12_918ed48f23dfdc1fc95e3df9526b489c._comment | 9 ++++++--- doc/git-annex.mdwn | 4 ++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Annex/Perms.hs b/Annex/Perms.hs index 011ac8b085..6681da7e07 100644 --- a/Annex/Perms.hs +++ b/Annex/Perms.hs @@ -114,7 +114,7 @@ createAnnexDirectory dir = do top <- parentDir <$> fromRepo gitAnnexDir tops <- annexDbDir <$> Annex.getGitConfig >>= return . \case Nothing -> [top] - Just dbdir -> [top, parentDir dbdir] + Just dbdir -> [top, parentDir (parentDir dbdir)] createDirectoryUnder' tops dir createdir where createdir p = do diff --git a/Database/Init.hs b/Database/Init.hs index 0ccde7b19f..570cf5b32a 100644 --- a/Database/Init.hs +++ b/Database/Init.hs @@ -38,7 +38,7 @@ initDb db migration = do gc <- Annex.getGitConfig top <- parentDir <$> fromRepo gitAnnexDir let tops = case annexDbDir gc of - Just topdbdir -> [top, parentDir topdbdir] + Just topdbdir -> [top, parentDir (parentDir topdbdir)] Nothing -> [top] liftIO $ do createDirectoryUnder tops tmpdbdir diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs index d6b54e1852..22a299c480 100644 --- a/Types/GitConfig.hs +++ b/Types/GitConfig.hs @@ -53,6 +53,7 @@ import Control.Concurrent.STM import qualified Data.Set as S import qualified Data.Map as M import qualified Data.ByteString as B +import qualified System.FilePath.ByteString as P -- | A configurable value, that may not be fully determined yet because -- the global git config has not yet been loaded. @@ -213,7 +214,8 @@ extractGitConfig configsource r = GitConfig , annexPidLock = getbool (annexConfig "pidlock") False , annexPidLockTimeout = Seconds $ fromMaybe 300 $ getmayberead (annexConfig "pidlocktimeout") - , annexDbDir = toRawFilePath <$> getmaybe (annexConfig "dbdir") + , annexDbDir = (\d -> toRawFilePath d P. fromUUID hereuuid) + <$> getmaybe (annexConfig "dbdir") , annexAddUnlocked = configurable Nothing $ fmap Just $ getmaybe (annexConfig "addunlocked") , annexSecureHashesOnly = getbool (annexConfig "securehashesonly") False diff --git a/doc/bugs/crippled_filesystem__58___SQLite3_returned_ErrorBusy/comment_12_918ed48f23dfdc1fc95e3df9526b489c._comment b/doc/bugs/crippled_filesystem__58___SQLite3_returned_ErrorBusy/comment_12_918ed48f23dfdc1fc95e3df9526b489c._comment index 245f57955b..1837965358 100644 --- a/doc/bugs/crippled_filesystem__58___SQLite3_returned_ErrorBusy/comment_12_918ed48f23dfdc1fc95e3df9526b489c._comment +++ b/doc/bugs/crippled_filesystem__58___SQLite3_returned_ErrorBusy/comment_12_918ed48f23dfdc1fc95e3df9526b489c._comment @@ -3,11 +3,14 @@ subject="""comment 12""" date="2022-08-12T17:07:51Z" content=""" -annex.dbdir is now implemented. +annex.dbdir is now implemented. Note that it can safely be set to the same +path in several repositories. If all your repositories were on cifs, +you could even set it globally. This issue remains open because `git-annex init` ought to probe to determine when sqlite cannot be used on the repository's filesystem. I don't think it could itself set annex.dbdir to work around the -problem, because what would it set it to? But it could explain the problem -to the user and suggest that they set it. +problem, because what would it set it to? Maybe +`~/.cache/git-annex/something`? Seems better for it to explain the +problem to the user and suggest that they set it. """]] diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index a401596ef3..373444d796 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -1237,6 +1237,10 @@ repository, using [[git-annex-config]]. See its man page for a list.) that sqlite needs, and setting this to a directory on another filesystem can work around such a problem. + This can safely be set to the same directory in the configuration of + multiple repositories; each repository will use a subdirectory for its + sqlite database. + * `annex.cachecreds` When "true" (the default), git-annex will cache credentials used to