summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-29 23:32:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-29 23:32:32 -0400
commitc64b50a0ce725df2d5317b7ae4918b61aafa25ee (patch)
tree21ff1dceae32804dc1b6489638a7f15d8390a382 /CmdLine.hs
parent5584ccc8adbbcd629b3809fd39b5c00479fd0a25 (diff)
shutdown no longer a special case
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 308b04d1a..030637a73 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -32,7 +32,7 @@ dispatch :: Git.Repo -> [String] -> [Command] -> [Option] -> String -> IO ()
dispatch gitrepo args cmds options header = do
state <- Annex.new gitrepo allBackends
(actions, state') <- Annex.run state $ parseCmd args header cmds options
- tryRun state' $ [startup, upgrade] ++ actions
+ tryRun state' $ [startup, upgrade] ++ actions ++ [shutdown]
{- Parses command line, stores configure flags, and returns a
- list of actions to be run in the Annex monad. -}
@@ -73,7 +73,6 @@ usage header cmds options =
{- Runs a list of Annex actions. Catches IO errors and continues
- (but explicitly thrown errors terminate the whole command).
- - Runs shutdown and propigates an overall error status at the end.
-}
tryRun :: Annex.AnnexState -> [Annex Bool] -> IO ()
tryRun state actions = tryRun' state 0 actions
@@ -86,8 +85,7 @@ tryRun' state errnum (a:as) = do
tryRun' state (errnum + 1) as
Right (True,state') -> tryRun' state' errnum as
Right (False,state') -> tryRun' state' (errnum + 1) as
-tryRun' state errnum [] = do
- _ <- try $ Annex.run state $ shutdown errnum
+tryRun' _ errnum [] = do
when (errnum > 0) $ error $ show errnum ++ " failed"
{- Actions to perform each time ran. -}
@@ -97,9 +95,11 @@ startup = do
return True
{- Cleanup actions. -}
-shutdown :: Integer -> Annex ()
-shutdown errnum = do
+shutdown :: Annex Bool
+shutdown = do
q <- Annex.getState Annex.repoqueue
unless (q == GitQueue.empty) $ do
showSideAction "Recording state in git..."
Annex.queueRun
+
+ return True