fix incremental push to preserve existing bundle keys in manifest
Also broke Manifest out to its own type with a smart constructor. Sponsored-by: mycroft on Patreon
This commit is contained in:
parent
97b309b56e
commit
424afe46d7
3 changed files with 52 additions and 16 deletions
44
Types/GitRemoteAnnex.hs
Normal file
44
Types/GitRemoteAnnex.hs
Normal file
|
@ -0,0 +1,44 @@
|
|||
{- 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
|
||||
|
||||
-- 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]
|
||||
, outManifest :: [Key]
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- Smart constructor for Manifest. Preserves outManifest invariant.
|
||||
mkManifest
|
||||
:: [Key] -- ^ inManifest
|
||||
-> [Key] -- ^ outManifest
|
||||
-> Manifest
|
||||
mkManifest inks outks = Manifest inks (filter (`notElem` inks) outks)
|
||||
|
||||
instance Monoid Manifest where
|
||||
mempty = Manifest [] []
|
||||
|
||||
instance Sem.Semigroup Manifest where
|
||||
a <> b = mkManifest
|
||||
(inManifest a <> inManifest b)
|
||||
(outManifest a <> outManifest b)
|
Loading…
Add table
Add a link
Reference in a new issue