fixes for transfer resume

Fix resuming of downloads, which do not have a transfer info file to read.

When checking upload progress, use the MVar, rather than re-reading
the info file.

Catch exceptions in the transfer action. Required a tryAnnex.
This commit is contained in:
Joey Hess 2012-09-24 13:16:50 -04:00
parent 364b40e5fc
commit 3887432c54
3 changed files with 34 additions and 20 deletions

View file

@ -8,12 +8,13 @@
module Annex.Exception (
bracketIO,
handle,
tryAnnex,
throw,
) where
import Control.Exception.Lifted (handle)
import Control.Exception.Lifted (handle, try)
import Control.Monad.Trans.Control (liftBaseOp)
import Control.Exception hiding (handle, throw)
import Control.Exception hiding (handle, try, throw)
import Common.Annex
@ -22,6 +23,10 @@ bracketIO :: IO c -> (c -> IO b) -> Annex a -> Annex a
bracketIO setup cleanup go =
liftBaseOp (Control.Exception.bracket setup cleanup) (const go)
{- try in the Annex monad -}
tryAnnex :: Annex a -> Annex (Either SomeException a)
tryAnnex = try
{- Throws an exception in the Annex monad. -}
throw :: Control.Exception.Exception e => e -> Annex a
throw = liftIO . throwIO