add a push retry thread

This commit is contained in:
Joey Hess 2012-06-25 16:38:12 -04:00
parent 0b146f9ecc
commit 5cfe91f06d
5 changed files with 82 additions and 36 deletions

36
Assistant/Pushes.hs Normal file
View file

@ -0,0 +1,36 @@
{- git-annex assistant push tracking
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Assistant.Pushes where
import Common.Annex
import Utility.TSet
import Data.Time.Clock
type FailedPushChan = TSet FailedPush
data FailedPush = FailedPush
{ failedRemote :: Remote
, failedTimeStamp :: UTCTime
}
newFailedPushChan :: IO FailedPushChan
newFailedPushChan = newTSet
{- Gets all failed pushes. Blocks until there is at least one failed push. -}
getFailedPushes :: FailedPushChan -> IO [FailedPush]
getFailedPushes = getTSet
{- Puts failed pushes back into the channel.
- Note: Original order is not preserved. -}
refillFailedPushes :: FailedPushChan -> [FailedPush] -> IO ()
refillFailedPushes = putTSet
{- Records a failed push in the channel. -}
recordFailedPush :: FailedPushChan -> FailedPush -> IO ()
recordFailedPush = putTSet1