init: Automatically enable annex.pidlock when necessary.
This commit is contained in:
parent
c2cbe5619b
commit
bb86eebfbd
2 changed files with 29 additions and 1 deletions
|
@ -41,6 +41,7 @@ import Utility.UserInfo
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
import System.Posix.User
|
import System.Posix.User
|
||||||
|
import qualified Utility.LockFile.Posix as Posix
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
genDescription :: Maybe String -> Annex String
|
genDescription :: Maybe String -> Annex String
|
||||||
|
@ -74,9 +75,11 @@ initialize mdescription = do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
describeUUID u =<< genDescription mdescription
|
describeUUID u =<< genDescription mdescription
|
||||||
|
|
||||||
-- Everything except for uuid setup.
|
-- Everything except for uuid setup, shared clone setup, and initial
|
||||||
|
-- description.
|
||||||
initialize' :: Annex ()
|
initialize' :: Annex ()
|
||||||
initialize' = do
|
initialize' = do
|
||||||
|
checkLockSupport
|
||||||
checkFifoSupport
|
checkFifoSupport
|
||||||
checkCrippledFileSystem
|
checkCrippledFileSystem
|
||||||
unlessM isBare $
|
unlessM isBare $
|
||||||
|
@ -167,6 +170,24 @@ checkCrippledFileSystem = whenM probeCrippledFileSystem $ do
|
||||||
setConfig (ConfigKey "core.symlinks")
|
setConfig (ConfigKey "core.symlinks")
|
||||||
(Git.Config.boolConfig False)
|
(Git.Config.boolConfig False)
|
||||||
|
|
||||||
|
probeLockSupport :: Annex Bool
|
||||||
|
probeLockSupport = do
|
||||||
|
#ifdef mingw32_HOST_OS
|
||||||
|
return True
|
||||||
|
#else
|
||||||
|
tmp <- fromRepo gitAnnexTmpMiscDir
|
||||||
|
let f = tmp </> "lockprobe"
|
||||||
|
createAnnexDirectory tmp
|
||||||
|
mode <- annexFileMode
|
||||||
|
liftIO $ do
|
||||||
|
nukeFile f
|
||||||
|
ok <- catchBoolIO $ do
|
||||||
|
Posix.dropLock =<< Posix.lockExclusive (Just mode) f
|
||||||
|
return True
|
||||||
|
nukeFile f
|
||||||
|
return ok
|
||||||
|
#endif
|
||||||
|
|
||||||
probeFifoSupport :: Annex Bool
|
probeFifoSupport :: Annex Bool
|
||||||
probeFifoSupport = do
|
probeFifoSupport = do
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
|
@ -188,6 +209,12 @@ probeFifoSupport = do
|
||||||
return $ either (const False) isNamedPipe ms
|
return $ either (const False) isNamedPipe ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
checkLockSupport :: Annex ()
|
||||||
|
checkLockSupport = unlessM probeLockSupport $ do
|
||||||
|
warning "Detected a filesystem without POSIX fcntl lock support."
|
||||||
|
warning "Enabling annex.pidlock."
|
||||||
|
setConfig (annexConfig "pidlock") (Git.Config.boolConfig True)
|
||||||
|
|
||||||
checkFifoSupport :: Annex ()
|
checkFifoSupport :: Annex ()
|
||||||
checkFifoSupport = unlessM probeFifoSupport $ do
|
checkFifoSupport = unlessM probeFifoSupport $ do
|
||||||
warning "Detected a filesystem without fifo support."
|
warning "Detected a filesystem without fifo support."
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -29,6 +29,7 @@ git-annex (5.20151102.2) UNRELEASED; urgency=medium
|
||||||
that were missed before.
|
that were missed before.
|
||||||
* Added annex.pidlock and annex.pidlocktimeout configuration to support
|
* Added annex.pidlock and annex.pidlocktimeout configuration to support
|
||||||
filesystems where POSIX fcntl locks cannot be used.
|
filesystems where POSIX fcntl locks cannot be used.
|
||||||
|
* init: Automatically enable annex.pidlock when necessary.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Wed, 04 Nov 2015 12:50:20 -0400
|
-- Joey Hess <id@joeyh.name> Wed, 04 Nov 2015 12:50:20 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue