simplify interface by removing size
Add size to the returned key after the fact, unless the remote happened to add it itself.
This commit is contained in:
parent
85cd79ea01
commit
57cceac569
3 changed files with 8 additions and 4 deletions
|
@ -391,7 +391,11 @@ importKeys remote importtreeconfig importcontent importablecontents = do
|
||||||
Nothing -> error "internal" -- checked earlier
|
Nothing -> error "internal" -- checked earlier
|
||||||
Just a -> do
|
Just a -> do
|
||||||
let importer p = do
|
let importer p = do
|
||||||
k <- a loc cid sz p
|
unsizedk <- a loc cid p
|
||||||
|
-- This avoids every remote needing
|
||||||
|
-- to add the size.
|
||||||
|
let k = alterKey unsizedk $ \kd -> kd
|
||||||
|
{ keySize = keySize kd <|> Just sz }
|
||||||
checkSecureHashes k >>= \case
|
checkSecureHashes k >>= \case
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
recordcidkey cidmap db cid k
|
recordcidkey cidmap db cid k
|
||||||
|
|
|
@ -350,8 +350,8 @@ guardSameContentIdentifiers cont old new
|
||||||
| new == Just old = cont
|
| new == Just old = cont
|
||||||
| otherwise = giveup "file content has changed"
|
| otherwise = giveup "file content has changed"
|
||||||
|
|
||||||
importKeyM :: FilePath -> ExportLocation -> ContentIdentifier -> ByteSize -> MeterUpdate -> Annex Key
|
importKeyM :: FilePath -> ExportLocation -> ContentIdentifier -> MeterUpdate -> Annex Key
|
||||||
importKeyM dir loc cid sz p = do
|
importKeyM dir loc cid p = do
|
||||||
backend <- chooseBackend (fromRawFilePath f)
|
backend <- chooseBackend (fromRawFilePath f)
|
||||||
k <- fst <$> genKey ks p backend
|
k <- fst <$> genKey ks p backend
|
||||||
currcid <- liftIO $ mkContentIdentifier absf =<< getFileStatus absf
|
currcid <- liftIO $ mkContentIdentifier absf =<< getFileStatus absf
|
||||||
|
|
|
@ -287,7 +287,7 @@ data ImportActions a = ImportActions
|
||||||
-- since the ContentIdentifier was generated.
|
-- since the ContentIdentifier was generated.
|
||||||
--
|
--
|
||||||
-- Throws exception on failure.
|
-- Throws exception on failure.
|
||||||
, importKey :: Maybe (ExportLocation -> ContentIdentifier -> ByteSize -> MeterUpdate -> a Key)
|
, importKey :: Maybe (ExportLocation -> ContentIdentifier -> MeterUpdate -> a Key)
|
||||||
-- Retrieves a file from the remote. Ensures that the file
|
-- Retrieves a file from the remote. Ensures that the file
|
||||||
-- it retrieves has the requested ContentIdentifier.
|
-- it retrieves has the requested ContentIdentifier.
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue