55bf01b788
When downloading a VURL from the web, make sure that the equivilant key log is populated. Unfortunately, this does not hash the content while it's being downloaded from the web. There is not an interface in Backend currently for incrementally hash generation, only for incremental verification of an existing hash. So this might add a noticiable delay, and it has to show a "(checksum...") message. This could stand to be improved. But, that separate hashing step only has to happen on the first download of new content from the web. Once the hash is known, the VURL key can have its hash verified incrementally while downloading except when the content in the web has changed. (Doesn't happen yet because verifyKeyContentIncrementally is not implemented yet for VURL keys.) Note that the equivilant key log file is formatted as a presence log. This adds a tiny bit of overhead (eg "1 ") per line over just listing the urls. The reason I chose to use that format is it seems possible that there will need to be a way to remove an equivilant key at some point in the future. I don't know why that would be necessary, but it seemed wise to allow for the possibility. Downloads of VURL keys from other special remotes that claim urls, like bittorrent for example, does not popilate the equivilant key log. So for now, no checksum verification will be done for those. Sponsored-by: Nicholas Golder-Manning on Patreon
31 lines
801 B
Haskell
31 lines
801 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
|
|
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))
|