diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-23 14:59:58 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-23 14:59:58 -0400 |
commit | 1aee8106ac52b8337a12eb7b29bdf2ce2f3b4ca0 (patch) | |
tree | e913b730bab350207734a36d9dc2fd05d2393427 /Database/Fsck.hs | |
parent | 8693130a22747fe90c6f950ee43d56ebc8a7c236 (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/Fsck.hs')
-rw-r--r-- | Database/Fsck.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Database/Fsck.hs b/Database/Fsck.hs index b0e56f6c0..d176690a6 100644 --- a/Database/Fsck.hs +++ b/Database/Fsck.hs @@ -21,7 +21,7 @@ module Database.Fsck ( ) where import Database.Types -import qualified Database.Handle as H +import qualified Database.Queue as H import Locations import Utility.PosixFiles import Utility.Exception @@ -37,7 +37,7 @@ import Database.Persist.TH import Database.Esqueleto hiding (Key) import Data.Time.Clock -data FsckHandle = FsckHandle H.DbHandle UUID +data FsckHandle = FsckHandle H.DbQueue UUID {- Each key stored in the database has already been fscked as part - of the latest incremental fsck pass. -} @@ -77,7 +77,7 @@ openDb u = do void $ tryIO $ removeDirectoryRecursive dbdir rename tmpdbdir dbdir lockFileCached =<< fromRepo (gitAnnexFsckDbLock u) - h <- liftIO $ H.openDb db "fscked" + h <- liftIO $ H.openDbQueue db "fscked" -- work around https://github.com/yesodweb/persistent/issues/474 liftIO setConsoleEncoding @@ -86,7 +86,7 @@ openDb u = do closeDb :: FsckHandle -> Annex () closeDb (FsckHandle h u) = do - liftIO $ H.closeDb h + liftIO $ H.closeDbQueue h unlockFile =<< fromRepo (gitAnnexFsckDbLock u) addDb :: FsckHandle -> Key -> IO () @@ -102,8 +102,9 @@ addDb (FsckHandle h _) k = H.queueDb h checkcommit $ now <- getCurrentTime return $ diffUTCTime lastcommittime now > 300 +{- Doesn't know about keys that were just added with addDb. -} inDb :: FsckHandle -> Key -> IO Bool -inDb (FsckHandle h _) = H.queryDb h . inDb' . toSKey +inDb (FsckHandle h _) = H.queryDbQueue h . inDb' . toSKey inDb' :: SKey -> SqlPersistM Bool inDb' sk = do |