From 89578d4d3fc3004f04fa84ba933d5d91e0cca868 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 19 Jul 2016 12:12:19 -0400 Subject: Avoid any access to keys database in v5 mode repositories, which are not supposed to use that database. --- Database/Keys.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Database') diff --git a/Database/Keys.hs b/Database/Keys.hs index 778540137..73c9a5bff 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -27,6 +27,7 @@ import Database.Keys.Handle import qualified Database.Queue as H import Annex.Locations import Annex.Common hiding (delete) +import Annex.Version (versionUsesKeysDatabase) import qualified Annex import Annex.Perms import Annex.LockFile @@ -53,9 +54,12 @@ import Database.Esqueleto hiding (Key) - Any queued writes will be flushed before the read. -} runReader :: Monoid v => (SQL.ReadHandle -> Annex v) -> Annex v -runReader a = do - h <- getDbHandle - withDbState h go +runReader a = ifM versionUsesKeysDatabase + ( do + h <- getDbHandle + withDbState h go + , return mempty + ) where go DbUnavailable = return (mempty, DbUnavailable) go st@(DbOpen qh) = do @@ -77,7 +81,7 @@ runReaderIO a = runReader (liftIO . a) - - The database is created if it doesn't exist yet. -} runWriter :: (SQL.WriteHandle -> Annex ()) -> Annex () -runWriter a = do +runWriter a = whenM versionUsesKeysDatabase $ do h <- getDbHandle withDbState h go where @@ -146,7 +150,8 @@ openDb createdb _ = catchPermissionDenied permerr $ withExclusiveLock gitAnnexKe - data to it. -} closeDb :: Annex () -closeDb = liftIO . closeDbHandle =<< getDbHandle +closeDb = whenM versionUsesKeysDatabase $ + liftIO . closeDbHandle =<< getDbHandle addAssociatedFile :: Key -> TopFilePath -> Annex () addAssociatedFile k f = runWriterIO $ SQL.addAssociatedFile (toIKey k) f -- cgit v1.2.3