summaryrefslogtreecommitdiff
path: root/Assistant.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-15 23:24:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-15 23:29:39 -0400
commit0052cec2b7e39652bd52cd4978ed47d2daa5af68 (patch)
tree2c9b2262988886e95f3c45716913dc51502605a3 /Assistant.hs
parent5d63c2a4bbf910c859e873f6e27aef3453992b43 (diff)
add lsof build deps
Check for it in configure; and add a --force option for people without it who want to live dangerously.
Diffstat (limited to 'Assistant.hs')
-rw-r--r--Assistant.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/Assistant.hs b/Assistant.hs
index b72f9a7e7..4042c6ede 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -49,8 +49,10 @@ import Assistant.DaemonStatus
import Assistant.Watcher
import Assistant.Committer
import Assistant.SanityChecker
+import qualified Annex
import qualified Utility.Daemon
import Utility.LogFile
+import qualified Build.SysConfig as SysConfig
import Control.Concurrent
@@ -64,7 +66,12 @@ startDaemon foreground
pidfile <- fromRepo gitAnnexPidFile
go $ Utility.Daemon.daemonize logfd (Just pidfile) False
where
- go a = withThreadState $ \st -> do
+ go a
+ | SysConfig.lsof = start a
+ | otherwise =
+ ifM (Annex.getState Annex.force)
+ (start a, needlsof)
+ start a = withThreadState $ \st -> do
dstatus <- startDaemonStatus
liftIO $ a $ do
changechan <- newChangeChan
@@ -78,5 +85,17 @@ startDaemon foreground
_ <- forkIO $ sanityCheckerThread st dstatus changechan
watchThread st dstatus changechan
+ -- this message is optimised away when lsof is available
+ needlsof = error $ unlines
+ [ "The lsof command is needed for watch mode to be safe."
+ , "But this build of git-annex was made without lsof available. Giving up..."
+ , ""
+ , "You can use --force if lsof is available now. Please make very sure it is."
+ , "If run with --force and without lsof available, files can be added to the"
+ , "annex while a process still has them opened for writing. This can"
+ , "corrupt data in the annex, and make fsck complain."
+ , "Use the --force with caution, Luke!"
+ ]
+
stopDaemon :: Annex ()
stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile