summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-26 12:04:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-26 12:04:35 -0400
commitabf47bf25aea42a96fffc4cd8ca4e3c9406d4fbd (patch)
tree46ab77ee730c4aab5618219bf34d07c88e1c74e5
parentc3c63e48dfb3c981786bd3178e5f5689d3c60abf (diff)
reorg
-rw-r--r--Remote/Helper/Chunked.hs12
-rw-r--r--Remote/Helper/Encryptable.hs28
2 files changed, 17 insertions, 23 deletions
diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs
index e98400100..e298299ce 100644
--- a/Remote/Helper/Chunked.hs
+++ b/Remote/Helper/Chunked.hs
@@ -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
diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs
index 41174cf7c..c450a1084 100644
--- a/Remote/Helper/Encryptable.hs
+++ b/Remote/Helper/Encryptable.hs
@@ -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