aboutsummaryrefslogtreecommitdiff
path: root/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-10 23:35:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-10 23:45:14 -0400
commitb327227ba596d4fc5012138d03390c3eb861b808 (patch)
tree921c3ca6851d1ede45c387d9fd54997dcbf44906 /Command.hs
parent4389782628a1cc683ef238e848b6311fc4bd82c3 (diff)
better limiting of start actions to only run whenAnnexed
Mostly only refactoring, but this does remove one redundant stat of the symlink by copy.
Diffstat (limited to 'Command.hs')
-rw-r--r--Command.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Command.hs b/Command.hs
index c436c5b62..083be37f2 100644
--- a/Command.hs
+++ b/Command.hs
@@ -15,8 +15,8 @@ module Command (
stop,
prepCommand,
doCommand,
+ whenAnnexed,
notAnnexed,
- isAnnexed,
notBareRepo,
isBareRepo,
autoCopies
@@ -65,12 +65,14 @@ doCommand = start
failure = showEndFail >> return False
status r = showEndResult r >> return r
+{- Modifies an action to only act on files that are already annexed,
+ - and passes the key and backend on to it. -}
+whenAnnexed :: (FilePath -> (Key, Backend Annex) -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
+whenAnnexed a file = maybe (return Nothing) (a file) =<< Backend.lookupFile file
+
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file
-isAnnexed :: FilePath -> ((Key, Backend Annex) -> Annex (Maybe a)) -> Annex (Maybe a)
-isAnnexed file a = maybe (return Nothing) a =<< Backend.lookupFile file
-
notBareRepo :: Annex a -> Annex a
notBareRepo a = do
whenM isBareRepo $