avoid annexFileMode special case
This makes annexFileMode be just an application of setAnnexPerm', which avoids having 2 functions that do different versions of the same thing. Fixes some buggy behavior for some combinations of core.sharedRepository and umask. Sponsored-by: Jack Hill on Patreon
This commit is contained in:
parent
67f8268b3f
commit
aff37fc208
13 changed files with 82 additions and 69 deletions
|
@ -26,6 +26,7 @@ import qualified Annex
|
|||
import qualified Utility.LockPool.Posix as Posix
|
||||
import qualified Utility.LockPool.PidLock as Pid
|
||||
import qualified Utility.LockPool.LockHandle as H
|
||||
import Utility.FileMode
|
||||
import Utility.LockPool.LockHandle (LockHandle, dropLock)
|
||||
import Utility.LockFile.Posix (openLockFile)
|
||||
import Utility.LockPool.STM (LockFile, LockMode(..))
|
||||
|
@ -36,16 +37,16 @@ import Git.Quote
|
|||
|
||||
import System.Posix
|
||||
|
||||
lockShared :: Maybe FileMode -> LockFile -> Annex LockHandle
|
||||
lockShared :: Maybe ModeSetter -> LockFile -> Annex LockHandle
|
||||
lockShared m f = pidLock m f LockShared $ Posix.lockShared m f
|
||||
|
||||
lockExclusive :: Maybe FileMode -> LockFile -> Annex LockHandle
|
||||
lockExclusive :: Maybe ModeSetter -> LockFile -> Annex LockHandle
|
||||
lockExclusive m f = pidLock m f LockExclusive $ Posix.lockExclusive m f
|
||||
|
||||
tryLockShared :: Maybe FileMode -> LockFile -> Annex (Maybe LockHandle)
|
||||
tryLockShared :: Maybe ModeSetter -> LockFile -> Annex (Maybe LockHandle)
|
||||
tryLockShared m f = tryPidLock m f LockShared $ Posix.tryLockShared m f
|
||||
|
||||
tryLockExclusive :: Maybe FileMode -> LockFile -> Annex (Maybe LockHandle)
|
||||
tryLockExclusive :: Maybe ModeSetter -> LockFile -> Annex (Maybe LockHandle)
|
||||
tryLockExclusive m f = tryPidLock m f LockExclusive $ Posix.tryLockExclusive m f
|
||||
|
||||
checkLocked :: LockFile -> Annex (Maybe Bool)
|
||||
|
@ -68,7 +69,7 @@ pidLockCheck :: IO a -> (LockFile -> IO a) -> Annex a
|
|||
pidLockCheck posixcheck pidcheck = debugLocks $
|
||||
liftIO . maybe posixcheck pidcheck =<< pidLockFile
|
||||
|
||||
pidLock :: Maybe FileMode -> LockFile -> LockMode -> IO LockHandle -> Annex LockHandle
|
||||
pidLock :: Maybe ModeSetter -> LockFile -> LockMode -> IO LockHandle -> Annex LockHandle
|
||||
pidLock m f lockmode posixlock = debugLocks $ go =<< pidLockFile
|
||||
where
|
||||
go Nothing = liftIO posixlock
|
||||
|
@ -77,7 +78,7 @@ pidLock m f lockmode posixlock = debugLocks $ go =<< pidLockFile
|
|||
liftIO $ dummyPosixLock m f
|
||||
Pid.waitLock f lockmode timeout pidlock (warning . UnquotedString)
|
||||
|
||||
tryPidLock :: Maybe FileMode -> LockFile -> LockMode -> IO (Maybe LockHandle) -> Annex (Maybe LockHandle)
|
||||
tryPidLock :: Maybe ModeSetter -> LockFile -> LockMode -> IO (Maybe LockHandle) -> Annex (Maybe LockHandle)
|
||||
tryPidLock m f lockmode posixlock = debugLocks $ liftIO . go =<< pidLockFile
|
||||
where
|
||||
go Nothing = posixlock
|
||||
|
@ -88,5 +89,5 @@ tryPidLock m f lockmode posixlock = debugLocks $ liftIO . go =<< pidLockFile
|
|||
-- The posix lock file is created even when using pid locks, in order to
|
||||
-- avoid complicating any code that might expect to be able to see that
|
||||
-- lock file. But, it's not locked.
|
||||
dummyPosixLock :: Maybe FileMode -> LockFile -> IO ()
|
||||
dummyPosixLock :: Maybe ModeSetter -> LockFile -> IO ()
|
||||
dummyPosixLock m f = bracket (openLockFile ReadLock m f) closeFd (const noop)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue