diff --git a/Annex/GitOverlay.hs b/Annex/GitOverlay.hs index 7370116d78..07a088fde1 100644 --- a/Annex/GitOverlay.hs +++ b/Annex/GitOverlay.hs @@ -24,7 +24,7 @@ import qualified Utility.LockFile.PidLock as PidF import qualified Utility.LockPool.PidLock as PidP import Utility.LockPool (dropLock) import Utility.Env -import Annex.LockPool.PosixOrPid (pidLockFile) +import Config {- Runs an action using a different git index file. -} withIndexFile :: AltIndexFile -> (FilePath -> Annex a) -> Annex a diff --git a/Annex/LockPool/PosixOrPid.hs b/Annex/LockPool/PosixOrPid.hs index 87e88c4a5d..632d967640 100644 --- a/Annex/LockPool/PosixOrPid.hs +++ b/Annex/LockPool/PosixOrPid.hs @@ -18,12 +18,10 @@ module Annex.LockPool.PosixOrPid ( LockStatus(..), getLockStatus, checkSaneLock, - pidLockFile, ) where import Common import Types -import Annex.Locations import qualified Annex import qualified Utility.LockPool.Posix as Posix import qualified Utility.LockPool.PidLock as Pid @@ -32,6 +30,7 @@ import Utility.LockPool.LockHandle (LockHandle, dropLock) import Utility.LockFile.Posix (openLockFile) import Utility.LockPool.STM (LockFile) import Utility.LockFile.LockStatus +import Config (pidLockFile) import System.Posix @@ -63,12 +62,6 @@ checkSaneLock :: LockFile -> LockHandle -> Annex Bool checkSaneLock f h = H.checkSaneLock f h `pidLockCheck` flip Pid.checkSaneLock h -pidLockFile :: Annex (Maybe FilePath) -pidLockFile = ifM (annexPidLock <$> Annex.getGitConfig) - ( Just <$> Annex.fromRepo gitAnnexPidLockFile - , pure Nothing - ) - pidLockCheck :: IO a -> (LockFile -> IO a) -> Annex a pidLockCheck posixcheck pidcheck = debugLocks $ liftIO . maybe posixcheck pidcheck =<< pidLockFile diff --git a/Config.hs b/Config.hs index c87c665224..00bb244afb 100644 --- a/Config.hs +++ b/Config.hs @@ -6,12 +6,14 @@ -} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module Config ( module Config, annexConfig, remoteAnnexConfig, remoteConfig, + pidLockFile, ) where import Annex.Common @@ -23,6 +25,7 @@ import Config.Cost import Config.DynamicConfig import Types.Availability import Types.GitConfig +import Annex.Locations import Git.Types {- Looks up a setting in git config. This is not as efficient as using the @@ -83,3 +86,13 @@ crippledFileSystem = annexCrippledFileSystem <$> Annex.getGitConfig setCrippledFileSystem :: Bool -> Annex () setCrippledFileSystem b = setConfig (annexConfig "crippledfilesystem") (Git.Config.boolConfig b) + +pidLockFile :: Annex (Maybe FilePath) +#ifndef mingw32_HOST_OS +pidLockFile = ifM (annexPidLock <$> Annex.getGitConfig) + ( Just <$> Annex.fromRepo gitAnnexPidLockFile + , pure Nothing + ) +#else +pidLockFile = pure Nothing +#endif