summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-11-13 13:35:29 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-11-13 13:35:29 -0400
commitc7829d71910ff9c50545a609fe7a09345f3393e6 (patch)
treebc3d6442dd86d0341ca5a596c9a2be820e707e67 /Annex
parent9f3d75f06c2d6f4ed6b86fb23f8dec52d8d53b85 (diff)
init: Automatically enable annex.pidlock when necessary.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Init.hs29
1 files changed, 28 insertions, 1 deletions
diff --git a/Annex/Init.hs b/Annex/Init.hs
index 03915904e..65e9aa474 100644
--- a/Annex/Init.hs
+++ b/Annex/Init.hs
@@ -41,6 +41,7 @@ import Utility.UserInfo
import Utility.FileMode
import Annex.Perms
import System.Posix.User
+import qualified Utility.LockFile.Posix as Posix
#endif
genDescription :: Maybe String -> Annex String
@@ -74,9 +75,11 @@ initialize mdescription = do
u <- getUUID
describeUUID u =<< genDescription mdescription
--- Everything except for uuid setup.
+-- Everything except for uuid setup, shared clone setup, and initial
+-- description.
initialize' :: Annex ()
initialize' = do
+ checkLockSupport
checkFifoSupport
checkCrippledFileSystem
unlessM isBare $
@@ -167,6 +170,24 @@ checkCrippledFileSystem = whenM probeCrippledFileSystem $ do
setConfig (ConfigKey "core.symlinks")
(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 = do
#ifdef mingw32_HOST_OS
@@ -188,6 +209,12 @@ probeFifoSupport = do
return $ either (const False) isNamedPipe ms
#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 = unlessM probeFifoSupport $ do
warning "Detected a filesystem without fifo support."