shutdown no longer a special case
This commit is contained in:
parent
5584ccc8ad
commit
c64b50a0ce
2 changed files with 7 additions and 7 deletions
12
CmdLine.hs
12
CmdLine.hs
|
@ -32,7 +32,7 @@ dispatch :: Git.Repo -> [String] -> [Command] -> [Option] -> String -> IO ()
|
||||||
dispatch gitrepo args cmds options header = do
|
dispatch gitrepo args cmds options header = do
|
||||||
state <- Annex.new gitrepo allBackends
|
state <- Annex.new gitrepo allBackends
|
||||||
(actions, state') <- Annex.run state $ parseCmd args header cmds options
|
(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
|
{- Parses command line, stores configure flags, and returns a
|
||||||
- list of actions to be run in the Annex monad. -}
|
- 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
|
{- Runs a list of Annex actions. Catches IO errors and continues
|
||||||
- (but explicitly thrown errors terminate the whole command).
|
- (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 :: Annex.AnnexState -> [Annex Bool] -> IO ()
|
||||||
tryRun state actions = tryRun' state 0 actions
|
tryRun state actions = tryRun' state 0 actions
|
||||||
|
@ -86,8 +85,7 @@ tryRun' state errnum (a:as) = do
|
||||||
tryRun' state (errnum + 1) as
|
tryRun' state (errnum + 1) as
|
||||||
Right (True,state') -> tryRun' state' errnum as
|
Right (True,state') -> tryRun' state' errnum as
|
||||||
Right (False,state') -> tryRun' state' (errnum + 1) as
|
Right (False,state') -> tryRun' state' (errnum + 1) as
|
||||||
tryRun' state errnum [] = do
|
tryRun' _ errnum [] = do
|
||||||
_ <- try $ Annex.run state $ shutdown errnum
|
|
||||||
when (errnum > 0) $ error $ show errnum ++ " failed"
|
when (errnum > 0) $ error $ show errnum ++ " failed"
|
||||||
|
|
||||||
{- Actions to perform each time ran. -}
|
{- Actions to perform each time ran. -}
|
||||||
|
@ -97,9 +95,11 @@ startup = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
{- Cleanup actions. -}
|
{- Cleanup actions. -}
|
||||||
shutdown :: Integer -> Annex ()
|
shutdown :: Annex Bool
|
||||||
shutdown errnum = do
|
shutdown = do
|
||||||
q <- Annex.getState Annex.repoqueue
|
q <- Annex.getState Annex.repoqueue
|
||||||
unless (q == GitQueue.empty) $ do
|
unless (q == GitQueue.empty) $ do
|
||||||
showSideAction "Recording state in git..."
|
showSideAction "Recording state in git..."
|
||||||
Annex.queueRun
|
Annex.queueRun
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
|
@ -38,6 +38,6 @@ start keyname = do
|
||||||
then do
|
then do
|
||||||
-- forcibly quit after receiving one key,
|
-- forcibly quit after receiving one key,
|
||||||
-- and shutdown cleanly so queued git commands run
|
-- and shutdown cleanly so queued git commands run
|
||||||
_ <- shutdown 0
|
_ <- shutdown
|
||||||
liftIO exitSuccess
|
liftIO exitSuccess
|
||||||
else liftIO exitFailure
|
else liftIO exitFailure
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue