reorg
This commit is contained in:
parent
e4cb50db33
commit
cf83697c33
2 changed files with 17 additions and 23 deletions
|
@ -63,16 +63,12 @@ takeChunkKeyStream n (ChunkKeyStream l) = genericTake n l
|
||||||
numChunks :: ChunkKeyStream -> Integer
|
numChunks :: ChunkKeyStream -> Integer
|
||||||
numChunks = pred . fromJust . keyChunkNum . fst . nextChunkKeyStream
|
numChunks = pred . fromJust . keyChunkNum . fst . nextChunkKeyStream
|
||||||
|
|
||||||
{- Slits up the key's content into chunks, passing each chunk to
|
{- Splits up the key's content into chunks, passing each chunk to
|
||||||
- the storer action, along with a unique chunk key.
|
- 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
|
- Note that the storer action is responsible for catching any
|
||||||
- exceptions it may encounter.
|
- 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 :: 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 ->
|
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.
|
-- even for empty content.
|
||||||
| not (null c) || numchunks == 0 =
|
| not (null c) || numchunks == 0 =
|
||||||
storechunk bytesprocessed sz [] c chunkkeys
|
storechunk bytesprocessed sz [] c chunkkeys
|
||||||
|
-- Once all chunks are successfully stored,
|
||||||
|
-- update the chunk log.
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
chunksStored u k chunksize numchunks
|
chunksStored u k chunksize numchunks
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -80,28 +80,24 @@ encryptableRemote
|
||||||
-> ((Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool)
|
-> ((Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool)
|
||||||
-> Remote
|
-> Remote
|
||||||
-> Remote
|
-> Remote
|
||||||
encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
|
encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r = r
|
||||||
r {
|
{ storeKey = \k f p -> cip k >>= maybe
|
||||||
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
|
|
||||||
(storeKey r k f p)
|
(storeKey r k f p)
|
||||||
(\enck -> storeKeyEncrypted enck k 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)
|
(retrieveKeyFile r k f d p)
|
||||||
(\enck -> retrieveKeyFileEncrypted enck k d p)
|
(\enck -> retrieveKeyFileEncrypted enck k d p)
|
||||||
retrieveCheap k d = cip k >>= maybe
|
, retrieveKeyFileCheap = \k d -> cip k >>= maybe
|
||||||
(retrieveKeyFileCheap r k d)
|
(retrieveKeyFileCheap r k d)
|
||||||
(\_ -> return False)
|
(\_ -> 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)
|
withkey a k = cip k >>= maybe (a k) (a . snd)
|
||||||
cip = cipherKey c
|
cip = cipherKey c
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue