2024-05-13 13:33:15 +00:00
|
|
|
{- git-remote-annex types
|
|
|
|
-
|
|
|
|
- Copyright 2024 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Types.GitRemoteAnnex
|
|
|
|
( Manifest
|
|
|
|
, mkManifest
|
|
|
|
, inManifest
|
|
|
|
, outManifest
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Types.Key
|
|
|
|
|
|
|
|
import qualified Data.Semigroup as Sem
|
2024-05-24 19:10:56 +00:00
|
|
|
import qualified Data.Set as S
|
2024-05-13 13:33:15 +00:00
|
|
|
|
|
|
|
-- The manifest contains an ordered list of git bundle keys.
|
|
|
|
--
|
|
|
|
-- There is a second list of git bundle keys that are no longer
|
|
|
|
-- used and should be deleted. This list should never contain keys
|
|
|
|
-- that are in the first list.
|
|
|
|
data Manifest =
|
|
|
|
Manifest
|
|
|
|
{ inManifest :: [Key]
|
2024-05-24 19:10:56 +00:00
|
|
|
, outManifest :: S.Set Key
|
2024-05-13 13:33:15 +00:00
|
|
|
}
|
|
|
|
deriving (Show)
|
|
|
|
|
|
|
|
-- Smart constructor for Manifest. Preserves outManifest invariant.
|
|
|
|
mkManifest
|
|
|
|
:: [Key] -- ^ inManifest
|
2024-05-24 19:10:56 +00:00
|
|
|
-> S.Set Key -- ^ outManifest
|
2024-05-13 13:33:15 +00:00
|
|
|
-> Manifest
|
2024-05-24 19:10:56 +00:00
|
|
|
mkManifest inks outks = Manifest inks (S.filter (`notElem` inks) outks)
|
2024-05-13 13:33:15 +00:00
|
|
|
|
|
|
|
instance Monoid Manifest where
|
2024-05-24 19:10:56 +00:00
|
|
|
mempty = Manifest mempty mempty
|
2024-05-13 13:33:15 +00:00
|
|
|
|
|
|
|
instance Sem.Semigroup Manifest where
|
|
|
|
a <> b = mkManifest
|
|
|
|
(inManifest a <> inManifest b)
|
2024-05-24 19:10:56 +00:00
|
|
|
(S.union (outManifest a) (outManifest b))
|