refactor
This commit is contained in:
parent
e6ae5e8d56
commit
d2091730e9
3 changed files with 36 additions and 31 deletions
|
@ -10,10 +10,8 @@ module Backend.VURL.Utilities where
|
|||
import Annex.Common
|
||||
import Types.Key
|
||||
import Types.Backend
|
||||
import Types.KeySource
|
||||
import Logs.EquivilantKeys
|
||||
import qualified Backend.Hash
|
||||
import Utility.Metered
|
||||
|
||||
migrateFromURLToVURL :: Key -> Backend -> AssociatedFile -> Bool -> Annex (Maybe Key)
|
||||
migrateFromURLToVURL oldkey newbackend _af inannex
|
||||
|
@ -41,26 +39,3 @@ migrateFromVURLToURL oldkey newbackend _af _
|
|||
(keyData oldkey)
|
||||
{ keyVariety = URLKey }
|
||||
| otherwise = return Nothing
|
||||
|
||||
-- The Backend must use a cryptographically secure hash.
|
||||
generateEquivilantKey :: Backend -> OsPath -> Annex (Maybe Key)
|
||||
generateEquivilantKey b f =
|
||||
case genKey b of
|
||||
Just genkey -> do
|
||||
showSideAction (UnquotedString Backend.Hash.descChecksum)
|
||||
Just <$> genkey source nullMeterUpdate
|
||||
Nothing -> return Nothing
|
||||
where
|
||||
source = KeySource
|
||||
{ keyFilename = mempty -- avoid adding any extension
|
||||
, contentLocation = f
|
||||
, inodeCache = Nothing
|
||||
}
|
||||
|
||||
recordVurlKey :: Backend -> OsPath -> Key -> [Key] -> Annex Bool
|
||||
recordVurlKey b f key eks = generateEquivilantKey b f >>= \case
|
||||
Nothing -> return False
|
||||
Just ek -> do
|
||||
unless (ek `elem` eks) $
|
||||
setEquivilantKey key ek
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue