diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-10 00:32:23 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-10 00:32:23 -0400 |
commit | c42733876bcb72d1b4c85de6bac73f1c73b216ad (patch) | |
tree | c3edc52aa7b5b90594def0cd9eb7d4d1b8fc12d2 /Annex/Journal.hs | |
parent | 200b8d462e46db7b6bb87ab832529199fff58247 (diff) |
refactor locking
Diffstat (limited to 'Annex/Journal.hs')
-rw-r--r-- | Annex/Journal.hs | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/Annex/Journal.hs b/Annex/Journal.hs index 4d9c6ab66..f34a7be1b 100644 --- a/Annex/Journal.hs +++ b/Annex/Journal.hs @@ -17,10 +17,7 @@ import Common.Annex import Annex.Exception import qualified Git import Annex.Perms - -#ifdef mingw32_HOST_OS -import Utility.WinLock -#endif +import Annex.LockFile {- Records content for a file in the branch to the journal. - @@ -121,19 +118,4 @@ data JournalLocked = ProduceJournalLocked {- Runs an action that modifies the journal, using locking to avoid - contention with other git-annex processes. -} lockJournal :: (JournalLocked -> Annex a) -> Annex a -lockJournal a = do - lockfile <- fromRepo gitAnnexJournalLock - createAnnexDirectory $ takeDirectory lockfile - mode <- annexFileMode - bracketIO (lock lockfile mode) unlock (const $ a ProduceJournalLocked) - where -#ifndef mingw32_HOST_OS - lock lockfile mode = do - l <- noUmask mode $ createFile lockfile mode - waitToSetLock l (WriteLock, AbsoluteSeek, 0, 0) - return l - unlock = closeFd -#else - lock lockfile _mode = waitToLock $ lockExclusive lockfile - unlock = dropLock -#endif +lockJournal a = withExclusiveLock gitAnnexJournalLock $ a ProduceJournalLocked |