aboutsummaryrefslogtreecommitdiff
path: root/Database/Keys.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-23 14:59:58 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-23 14:59:58 -0400
commit1aee8106ac52b8337a12eb7b29bdf2ce2f3b4ca0 (patch)
treee913b730bab350207734a36d9dc2fd05d2393427 /Database/Keys.hs
parent8693130a22747fe90c6f950ee43d56ebc8a7c236 (diff)
split out Database.Queue from Database.Handle
Fsck can use the queue for efficiency since it is write-heavy, and only reads a value before writing it. But, the queue is not suited to the Keys database.
Diffstat (limited to 'Database/Keys.hs')
-rw-r--r--Database/Keys.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Database/Keys.hs b/Database/Keys.hs
index a0c5b1a04..425f1d54b 100644
--- a/Database/Keys.hs
+++ b/Database/Keys.hs
@@ -28,7 +28,7 @@ module Database.Keys (
import Database.Types
import Database.Keys.Types
-import qualified Database.Handle as H
+import qualified Database.Queue as H
import Locations
import Common hiding (delete)
import Annex
@@ -72,7 +72,7 @@ openDb = withExclusiveLock gitAnnexKeysDbLock $ do
runMigrationSilent migrateKeysDb
setAnnexDirPerm dbdir
setAnnexFilePerm db
- h <- liftIO $ H.openDb db "content"
+ h <- liftIO $ H.openDbQueue db "content"
-- work around https://github.com/yesodweb/persistent/issues/474
liftIO setConsoleEncoding
@@ -80,9 +80,9 @@ openDb = withExclusiveLock gitAnnexKeysDbLock $ do
return $ DbHandle h
closeDb :: DbHandle -> IO ()
-closeDb (DbHandle h) = H.closeDb h
+closeDb (DbHandle h) = H.closeDbQueue h
-withDbHandle :: (H.DbHandle -> IO a) -> Annex a
+withDbHandle :: (H.DbQueue -> IO a) -> Annex a
withDbHandle a = bracket openDb (liftIO . closeDb) (\(DbHandle h) -> liftIO (a h))
addAssociatedFile :: Key -> FilePath -> Annex ()
@@ -98,7 +98,7 @@ addAssociatedFile k f = withDbHandle $ \h -> H.queueDb h (\_ _ -> pure True) $ d
{- Note that the files returned were once associated with the key, but
- some of them may not be any longer. -}
getAssociatedFiles :: Key -> Annex [FilePath]
-getAssociatedFiles k = withDbHandle $ \h -> H.queryDb h $
+getAssociatedFiles k = withDbHandle $ \h -> H.queryDbQueue h $
getAssociatedFiles' $ toSKey k
getAssociatedFiles' :: SKey -> SqlPersistM [FilePath]
@@ -111,7 +111,7 @@ getAssociatedFiles' sk = do
{- Gets any keys that are on record as having a particular associated file.
- (Should be one or none but the database doesn't enforce that.) -}
getAssociatedKey :: FilePath -> Annex [Key]
-getAssociatedKey f = withDbHandle $ \h -> H.queryDb h $
+getAssociatedKey f = withDbHandle $ \h -> H.queryDbQueue h $
getAssociatedKey' f
getAssociatedKey' :: FilePath -> SqlPersistM [Key]
@@ -140,7 +140,7 @@ addInodeCaches k is = withDbHandle $ \h -> H.queueDb h (\_ _ -> pure True) $
{- A key may have multiple InodeCaches; one for the annex object, and one
- for each pointer file that is a copy of it. -}
getInodeCaches :: Key -> Annex [InodeCache]
-getInodeCaches k = withDbHandle $ \h -> H.queryDb h $ do
+getInodeCaches k = withDbHandle $ \h -> H.queryDbQueue h $ do
l <- select $ from $ \r -> do
where_ (r ^. ContentKey ==. val sk)
return (r ^. ContentCache)