summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-02 18:04:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-02 18:04:06 -0400
commit9a0635b05ddfccb4fd6831f3294af83030992ad5 (patch)
tree54735acb158d49027a65dd3dcd83c1d8cfa4ae8b /Assistant/Threads
parent8a12d8b5406aa99062470980510f6ea48a731d49 (diff)
avoid crashing committer if it fails to stage changes
Just retry later.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/Committer.hs36
1 files changed, 21 insertions, 15 deletions
diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs
index ab70e02bb..8fadafbd0 100644
--- a/Assistant/Threads/Committer.hs
+++ b/Assistant/Threads/Committer.hs
@@ -30,6 +30,7 @@ import qualified Utility.Lsof as Lsof
import qualified Utility.DirWatcher as DirWatcher
import Types.KeySource
import Config
+import Annex.Exception
import Data.Time.Clock
import Data.Tuple.Utils
@@ -81,18 +82,23 @@ commitThread st changechan commitchan transferqueue dstatus = thread $ do
commitStaged :: Annex Bool
commitStaged = do
- Annex.Queue.flush
- void $ inRepo $ Git.Command.runBool "commit" $ nomessage
- [ Param "--quiet"
- {- Avoid running the usual git-annex pre-commit hook;
- - watch does the same symlink fixing, and we don't want
- - to deal with unlocked files in these commits. -}
- , Param "--no-verify"
- ]
- {- Empty commits may be made if tree changes cancel
- - each other out, etc. Git returns nonzero on those, so
- - don't propigate out commit failures. -}
- return True
+ {- 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
+ [ Param "--quiet"
+ {- Avoid running the usual git-annex pre-commit hook;
+ - watch does the same symlink fixing, and we don't want
+ - to deal with unlocked files in these commits. -}
+ , Param "--no-verify"
+ ]
+ {- Empty commits may be made if tree changes cancel
+ - each other out, etc. Git returns nonzero on those,
+ - so don't propigate out commit failures. -}
+ return True
where
nomessage ps
| Git.Version.older "1.7.2" = Param "-m"
@@ -185,7 +191,7 @@ handleAdds delayadd st changechan transferqueue dstatus cs = returnWhen (null in
sanitycheck ks $ runThreadState st $ do
showStart "add" $ keyFilename ks
key <- Command.Add.ingest ks
- handle (finishedChange change) (keyFilename ks) key
+ done (finishedChange change) (keyFilename ks) key
where
{- Add errors tend to be transient and will
- be automatically dealt with, so don't
@@ -194,10 +200,10 @@ handleAdds delayadd st changechan transferqueue dstatus cs = returnWhen (null in
ret _ = (True, Nothing)
add _ = return Nothing
- handle _ _ Nothing = do
+ done _ _ Nothing = do
showEndFail
return Nothing
- handle change file (Just key) = do
+ done change file (Just key) = do
link <- Command.Add.link file key True
when DirWatcher.eventsCoalesce $ do
sha <- inRepo $