git-annex/Logs/EquivilantKeys.hs
Joey Hess 310a49a76d
nub the equivilant key list
If somehow the same key gets listed in the log twice, avoid doing double
checksumming.
2024-03-01 14:39:01 -04:00

31 lines
807 B
Haskell

{- Logs listing keys that are equivilant to a key.
-
- Copyright 2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE BangPatterns #-}
module Logs.EquivilantKeys (
getEquivilantKeys,
setEquivilantKey,
) where
import Annex.Common
import qualified Annex
import Logs
import Logs.Presence
import qualified Annex.Branch
getEquivilantKeys :: Key -> Annex [Key]
getEquivilantKeys key = do
config <- Annex.getGitConfig
nub . mapMaybe (deserializeKey' . fromLogInfo)
<$> presentLogInfo (equivilantKeysLogFile config key)
setEquivilantKey :: Key -> Key -> Annex ()
setEquivilantKey key equivkey = do
config <- Annex.getGitConfig
addLog (Annex.Branch.RegardingUUID []) (equivilantKeysLogFile config key)
InfoPresent (LogInfo (serializeKey' equivkey))