File: RepoProblem.hs

package info (click to toggle)
git-annex 8.20210223-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 68,764 kB
  • sloc: haskell: 70,359; javascript: 9,103; sh: 1,304; makefile: 212; perl: 136; ansic: 44
file content (34 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (5)
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 <id@joeyh.name>
 -
 - Licensed under the GNU AGPL 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