better data type for push records

Not yet plumbed thru
This commit is contained in:
Joey Hess 2012-06-26 12:36:42 -04:00
parent 75e8690cca
commit f2bce89055

View file

@ -8,29 +8,30 @@
module Assistant.Pushes where module Assistant.Pushes where
import Common.Annex import Common.Annex
import Utility.TSet import Control.Concurrent.SampleVar
import Data.Time.Clock import Data.Time.Clock
import qualified Data.Map as M
type FailedPushChan = TSet FailedPush {- Track the most recent push failure for each remote. -}
type PushMap = M.Map Remote UTCTime
data FailedPush = FailedPush type FailedPushes = SampleVar PushMap
{ failedRemote :: Remote
, failedTimeStamp :: UTCTime
}
newFailedPushChan :: IO FailedPushChan newFailedPushChan :: IO FailedPushChan
newFailedPushChan = newTSet newFailedPushChan = newEmptySampleVar
{- Gets all failed pushes. Blocks until there is at least one failed push. -} {- Gets all failed pushes. Blocks until set. -}
getFailedPushes :: FailedPushChan -> IO [FailedPush] getFailedPushes :: FailedPushChan -> IO PushMap
getFailedPushes = getTSet getFailedPushes = readSampleVar
{- Puts failed pushes back into the channel. {- Sets all failed pushes to passed PushMap -}
- Note: Original order is not preserved. -} setFailedPushes :: FailedPushChan -> PushMap -> IO ()
refillFailedPushes :: FailedPushChan -> [FailedPush] -> IO () setFailedPushes = writeSampleVar
refillFailedPushes = putTSet
{- Records a failed push in the channel. -} {- Indicates a failure to push to a single remote. -}
recordFailedPush :: FailedPushChan -> FailedPush -> IO () failedPush :: FailedPushChan -> Remote -> IO ()
recordFailedPush = putTSet1 failedPush c r =
{- Indicates that a remote was pushed to successfully. -}
successfulPush :: FailedPushChan -> Remote -> IO ()
successfulPush c r =