summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-17 14:02:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-17 14:21:29 -0400
commit1863185693f407a35f1b9e92d402e43409966928 (patch)
treeeabb3ecf7fb19e0d4d20146830e8f74444f512fc /Assistant
parente84b78f40c5ae20031c1d5cdde524081774de656 (diff)
startup check fixes
Move lsof check, and display a message before daemon startup if on an unsupported OS.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Watcher.hs22
1 files changed, 20 insertions, 2 deletions
diff --git a/Assistant/Watcher.hs b/Assistant/Watcher.hs
index 4aac33fd1..5af39ea88 100644
--- a/Assistant/Watcher.hs
+++ b/Assistant/Watcher.hs
@@ -13,13 +13,14 @@ import Common.Annex
import Assistant.ThreadedMonad
import Assistant.DaemonStatus
import Assistant.Committer
-import Utility.ThreadLock
+import Utility.ThreadScheduler
import qualified Annex.Queue
import qualified Git.Command
import qualified Git.UpdateIndex
import qualified Git.HashObject
import qualified Git.LsFiles
import qualified Backend
+import qualified Annex
import Annex.Content
import Annex.CatFile
import Git.Types
@@ -35,6 +36,23 @@ import System.INotify
type Handler = FilePath -> Maybe FileStatus -> DaemonStatusHandle -> Annex (Maybe Change)
+checkCanWatch :: Annex ()
+checkCanWatch = do
+#if defined linux_HOST_OS
+ unlessM (liftIO (inPath "lsof") <||> Annex.getState Annex.force) $
+ needLsof
+#else
+ error "watch mode is currently only available in Linux"
+#endif
+
+needLsof :: Annex ()
+needLsof = error $ unlines
+ [ "The lsof command is needed for watch mode to be safe, and is not in PATH."
+ , "To override lsof checks to ensure that files are not open for writing"
+ , "when added to the annex, you can use --force"
+ , "Be warned: This can corrupt data in the annex, and make fsck complain."
+ ]
+
watchThread :: ThreadState -> DaemonStatusHandle -> ChangeChan -> IO ()
#if defined linux_HOST_OS
watchThread st dstatus changechan = withINotify $ \i -> do
@@ -61,7 +79,7 @@ watchThread st dstatus changechan = withINotify $ \i -> do
, errHook = hook onErr
}
#else
-watchThread = error "so far only available on Linux"
+watchThread = undefined
#endif
ignored :: FilePath -> Bool