summaryrefslogtreecommitdiff
path: root/Checks.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-22 16:41:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-22 16:41:46 -0400
commit3cf16ebe5ea70e79bc4e45214265009ef7b975d0 (patch)
treed751054a064714d10ae70d75688fa1a1b3e9483f /Checks.hs
parentafec3a563930bb402b66d4c3c4c4c9c0572b1aa1 (diff)
direct, indirect: Refuse to do anything when the assistant or git-annex watch daemon is running.
Diffstat (limited to 'Checks.hs')
-rw-r--r--Checks.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Checks.hs b/Checks.hs
index 92e9f7e38..67aa51a2a 100644
--- a/Checks.hs
+++ b/Checks.hs
@@ -3,7 +3,7 @@
- Common sanity checks for commands, and an interface to selectively
- remove them, or add others.
-
- - Copyright 2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2011-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -14,6 +14,7 @@ import Common.Annex
import Types.Command
import Init
import Config
+import Utility.Daemon
import qualified Git
commonChecks :: [CommandCheck]
@@ -24,11 +25,17 @@ repoExists = CommandCheck 0 ensureInitialized
notDirect :: Command -> Command
notDirect = addCheck $ whenM isDirect $
- error "You cannot run this subcommand in a direct mode repository."
+ error "You cannot run this command in a direct mode repository."
notBareRepo :: Command -> Command
notBareRepo = addCheck $ whenM (fromRepo Git.repoIsLocalBare) $
- error "You cannot run this subcommand in a bare repository."
+ error "You cannot run this command in a bare repository."
+
+noDaemonRunning :: Command -> Command
+noDaemonRunning = addCheck $ whenM (isJust <$> daemonpid) $
+ error "You cannot run this command while git-annex watch or git-annex assistant is running."
+ where
+ daemonpid = liftIO . checkDaemon =<< fromRepo gitAnnexPidFile
dontCheck :: CommandCheck -> Command -> Command
dontCheck check cmd = mutateCheck cmd $ \c -> filter (/= check) c