summaryrefslogtreecommitdiff
path: root/Database
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-19 12:12:19 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-19 12:12:19 -0400
commit89578d4d3fc3004f04fa84ba933d5d91e0cca868 (patch)
tree5ef60bb1db1cd3e2733ca463fe3c5863283b9b26 /Database
parenta47769779d2602c35f5c0dc03bdd9acb56b0bf3d (diff)
Avoid any access to keys database in v5 mode repositories, which are not supposed to use that database.
Diffstat (limited to 'Database')
-rw-r--r--Database/Keys.hs15
1 files changed, 10 insertions, 5 deletions
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