aboutsummaryrefslogtreecommitdiff
path: root/Assistant/RepoProblem.hs
blob: 6913fefc62076dd5817f08de3894bbb15763fdcc (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
{- git-annex assistant remote problem handling
 -
 - Copyright 2013 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

module Assistant.RepoProblem where

import Assistant.Common
import Assistant.Types.RepoProblem
import Utility.TList

import Control.Concurrent.STM

{- Gets all repositories that have problems. Blocks until there is at
 - least one. -}
getRepoProblems :: Assistant [RepoProblem]
getRepoProblems = nubBy sameRepoProblem
	<$> (atomically . getTList) <<~ repoProblemChan

{- Indicates that there was a problem with a repository, and the problem
 - appears to not be a transient (eg network connection) problem.
 -
 - If the problem is able to be repaired, the passed action will be run.
 - (However, if multiple problems are reported with a single repository,
 - only a single action will be run.)
 -}
repoHasProblem :: UUID -> Assistant () -> Assistant ()
repoHasProblem u afterrepair = do
	rp <- RepoProblem
		<$> pure u
		<*> asIO afterrepair
	(atomically . flip consTList rp) <<~ repoProblemChan