summaryrefslogtreecommitdiff
path: root/Assistant/Pushes.hs
blob: f3bffbf7920538acc4b7a009f87926c016fcaefe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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