This commit is contained in:
Joey Hess 2014-07-26 12:04:35 -04:00
parent e4cb50db33
commit cf83697c33
2 changed files with 17 additions and 23 deletions

View file

@ -63,16 +63,12 @@ takeChunkKeyStream n (ChunkKeyStream l) = genericTake n l
numChunks :: ChunkKeyStream -> Integer
numChunks = pred . fromJust . keyChunkNum . fst . nextChunkKeyStream
{- Slits up the key's content into chunks, passing each chunk to
- the storer action, along with a unique chunk key.
{- Splits up the key's content into chunks, passing each chunk to
- the storer action, along with a corresponding chunk key and a
- progress meter update callback.
-
- Note that the storer action is responsible for catching any
- exceptions it may encounter.
-
- A progress meter display is set up, and the storer action
- is passed a callback to update it.
-
- Once all chunks are successfully stored, updates the chunk log.
-}
storeChunks :: UUID -> ChunkConfig -> Key -> FilePath -> MeterUpdate -> (Key -> L.ByteString -> MeterUpdate -> Annex Bool) -> Annex Bool
storeChunks u chunkconfig k f p storer = metered (Just p) k $ \meterupdate ->
@ -93,6 +89,8 @@ storeChunks u chunkconfig k f p storer = metered (Just p) k $ \meterupdate ->
-- even for empty content.
| not (null c) || numchunks == 0 =
storechunk bytesprocessed sz [] c chunkkeys
-- Once all chunks are successfully stored,
-- update the chunk log.
| otherwise = do
chunksStored u k chunksize numchunks
return True

View file

@ -80,28 +80,24 @@ encryptableRemote
-> ((Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool)
-> Remote
-> Remote
encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
r {
storeKey = store,
retrieveKeyFile = retrieve,
retrieveKeyFileCheap = retrieveCheap,
removeKey = withkey $ removeKey r,
hasKey = withkey $ hasKey r,
cost = maybe
(cost r)
(const $ cost r + encryptedRemoteCostAdj)
(extractCipher c)
}
where
store k f p = cip k >>= maybe
encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r = r
{ storeKey = \k f p -> cip k >>= maybe
(storeKey r k f p)
(\enck -> storeKeyEncrypted enck k p)
retrieve k f d p = cip k >>= maybe
, retrieveKeyFile = \k f d p -> cip k >>= maybe
(retrieveKeyFile r k f d p)
(\enck -> retrieveKeyFileEncrypted enck k d p)
retrieveCheap k d = cip k >>= maybe
, retrieveKeyFileCheap = \k d -> cip k >>= maybe
(retrieveKeyFileCheap r k d)
(\_ -> return False)
, removeKey = withkey $ removeKey r
, hasKey = withkey $ hasKey r
, cost = maybe
(cost r)
(const $ cost r + encryptedRemoteCostAdj)
(extractCipher c)
}
where
withkey a k = cip k >>= maybe (a k) (a . snd)
cip = cipherKey c