diff options
-rw-r--r-- | Annex.hs | 3 | ||||
-rw-r--r-- | Annex/Action.hs | 2 | ||||
-rw-r--r-- | Database/Keys.hs | 20 |
3 files changed, 1 insertions, 24 deletions
@@ -60,7 +60,6 @@ import Types.NumCopies import Types.LockCache import Types.DesktopNotify import Types.CleanupActions -import qualified Database.Keys.Types #ifdef WITH_QUVI import Utility.Quvi (QuviVersion) #endif @@ -135,7 +134,6 @@ data AnnexState = AnnexState , desktopnotify :: DesktopNotify , workers :: [Either AnnexState (Async AnnexState)] , concurrentjobs :: Maybe Int - , keysdbhandle :: Maybe Database.Keys.Types.DbHandle } newState :: GitConfig -> Git.Repo -> AnnexState @@ -181,7 +179,6 @@ newState c r = AnnexState , desktopnotify = mempty , workers = [] , concurrentjobs = Nothing - , keysdbhandle = Nothing } {- Makes an Annex state object for the specified git repo. diff --git a/Annex/Action.hs b/Annex/Action.hs index 348487e7c..f59c9c2f4 100644 --- a/Annex/Action.hs +++ b/Annex/Action.hs @@ -17,7 +17,6 @@ import System.Posix.Signals import Common.Annex import qualified Annex import Annex.Content -import qualified Database.Keys {- Actions to perform each time ran. -} startup :: Annex () @@ -33,5 +32,4 @@ shutdown :: Bool -> Annex () shutdown nocommit = do saveState nocommit sequence_ =<< M.elems <$> Annex.getState Annex.cleanup - Database.Keys.shutdown liftIO reapZombies -- zombies from long-running git processes diff --git a/Database/Keys.hs b/Database/Keys.hs index d4b5b3357..a0c5b1a04 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -14,7 +14,6 @@ module Database.Keys ( DbHandle, openDb, closeDb, - shutdown, addAssociatedFile, getAssociatedFiles, getAssociatedKey, @@ -84,24 +83,7 @@ closeDb :: DbHandle -> IO () closeDb (DbHandle h) = H.closeDb h withDbHandle :: (H.DbHandle -> IO a) -> Annex a -withDbHandle a = do - (DbHandle h) <- dbHandle - liftIO $ a h - -dbHandle :: Annex DbHandle -dbHandle = maybe startup return =<< Annex.getState Annex.keysdbhandle - where - startup = do - h <- openDb - Annex.changeState $ \s -> s { Annex.keysdbhandle = Just h } - return h - -shutdown :: Annex () -shutdown = maybe noop go =<< Annex.getState Annex.keysdbhandle - where - go h = do - Annex.changeState $ \s -> s { Annex.keysdbhandle = Nothing } - liftIO $ closeDb h +withDbHandle a = bracket openDb (liftIO . closeDb) (\(DbHandle h) -> liftIO (a h)) addAssociatedFile :: Key -> FilePath -> Annex () addAssociatedFile k f = withDbHandle $ \h -> H.queueDb h (\_ _ -> pure True) $ do |