avoid crashing committer if it fails to stage changes

Just retry later.
This commit is contained in:
Joey Hess 2012-10-02 18:04:06 -04:00
parent 9aab70de66
commit 9a3471971b

View file

@ -30,6 +30,7 @@ import qualified Utility.Lsof as Lsof
import qualified Utility.DirWatcher as DirWatcher import qualified Utility.DirWatcher as DirWatcher
import Types.KeySource import Types.KeySource
import Config import Config
import Annex.Exception
import Data.Time.Clock import Data.Time.Clock
import Data.Tuple.Utils import Data.Tuple.Utils
@ -81,7 +82,12 @@ commitThread st changechan commitchan transferqueue dstatus = thread $ do
commitStaged :: Annex Bool commitStaged :: Annex Bool
commitStaged = do commitStaged = do
Annex.Queue.flush {- This could fail if there's another commit being made by
- something else. -}
v <- tryAnnex Annex.Queue.flush
case v of
Left _ -> return False
Right _ -> do
void $ inRepo $ Git.Command.runBool "commit" $ nomessage void $ inRepo $ Git.Command.runBool "commit" $ nomessage
[ Param "--quiet" [ Param "--quiet"
{- Avoid running the usual git-annex pre-commit hook; {- Avoid running the usual git-annex pre-commit hook;
@ -90,8 +96,8 @@ commitStaged = do
, Param "--no-verify" , Param "--no-verify"
] ]
{- Empty commits may be made if tree changes cancel {- Empty commits may be made if tree changes cancel
- each other out, etc. Git returns nonzero on those, so - each other out, etc. Git returns nonzero on those,
- don't propigate out commit failures. -} - so don't propigate out commit failures. -}
return True return True
where where
nomessage ps nomessage ps
@ -185,7 +191,7 @@ handleAdds delayadd st changechan transferqueue dstatus cs = returnWhen (null in
sanitycheck ks $ runThreadState st $ do sanitycheck ks $ runThreadState st $ do
showStart "add" $ keyFilename ks showStart "add" $ keyFilename ks
key <- Command.Add.ingest ks key <- Command.Add.ingest ks
handle (finishedChange change) (keyFilename ks) key done (finishedChange change) (keyFilename ks) key
where where
{- Add errors tend to be transient and will {- Add errors tend to be transient and will
- be automatically dealt with, so don't - be automatically dealt with, so don't
@ -194,10 +200,10 @@ handleAdds delayadd st changechan transferqueue dstatus cs = returnWhen (null in
ret _ = (True, Nothing) ret _ = (True, Nothing)
add _ = return Nothing add _ = return Nothing
handle _ _ Nothing = do done _ _ Nothing = do
showEndFail showEndFail
return Nothing return Nothing
handle change file (Just key) = do done change file (Just key) = do
link <- Command.Add.link file key True link <- Command.Add.link file key True
when DirWatcher.eventsCoalesce $ do when DirWatcher.eventsCoalesce $ do
sha <- inRepo $ sha <- inRepo $