From a335c1e46e4e58aee0452f66c81dd83d51cec071 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Aug 2022 12:56:56 -0400 Subject: [PATCH] annex.dbdir fully working Completes work started in e60766543f0ae9eaa2ac8fdaff8fff5c66501beb I've verified that all the sqlite databases get stored in annex.dbdir and are created successfully. If annex.dbdir does not exist, it will be created; its parent directory must already exist though. Sponsored-by: Dartmouth College's Datalad project --- Annex/Perms.hs | 9 ++++++--- Database/Init.hs | 9 +++++---- doc/git-annex.mdwn | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Annex/Perms.hs b/Annex/Perms.hs index 73fa6172f1..011ac8b085 100644 --- a/Annex/Perms.hs +++ b/Annex/Perms.hs @@ -106,13 +106,16 @@ annexFileMode = withShared $ return . go go _ = stdFileMode sharedmode = combineModes groupSharedModes -{- Creates a directory inside the gitAnnexDir, creating any parent - - directories up to and including the gitAnnexDir. +{- Creates a directory inside the gitAnnexDir (or possibly the dbdir), + - creating any parent directories up to and including the gitAnnexDir. - Makes directories with appropriate permissions. -} createAnnexDirectory :: RawFilePath -> Annex () createAnnexDirectory dir = do top <- parentDir <$> fromRepo gitAnnexDir - createDirectoryUnder' [top] dir createdir + tops <- annexDbDir <$> Annex.getGitConfig >>= return . \case + Nothing -> [top] + Just dbdir -> [top, parentDir dbdir] + createDirectoryUnder' tops dir createdir where createdir p = do liftIO $ R.createDirectory p diff --git a/Database/Init.hs b/Database/Init.hs index 2b63a38513..0ccde7b19f 100644 --- a/Database/Init.hs +++ b/Database/Init.hs @@ -36,11 +36,12 @@ initDb db migration = do let tmpdb = tmpdbdir P. "db" let tdb = T.pack (fromRawFilePath tmpdb) gc <- Annex.getGitConfig - top <- case annexDbDir gc of - Just topdbdir -> pure $ parentDir $ topdbdir - Nothing -> parentDir <$> fromRepo gitAnnexDir + top <- parentDir <$> fromRepo gitAnnexDir + let tops = case annexDbDir gc of + Just topdbdir -> [top, parentDir topdbdir] + Nothing -> [top] liftIO $ do - createDirectoryUnder [top] tmpdbdir + createDirectoryUnder tops tmpdbdir runSqliteInfo (enableWAL tdb) migration setAnnexDirPerm tmpdbdir -- Work around sqlite bug that prevents it from honoring diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 3e8e4d138c..a401596ef3 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -1230,7 +1230,7 @@ repository, using [[git-annex-config]]. See its man page for a list.) * `annex.dbdir` - Set to a directory where git-annex should store its sqlite databases. + The directory where git-annex should store its sqlite databases. The default location is inside `.git/annex/`. Certian filesystems, such as cifs, may not support locking operations -- 2.30.2