summaryrefslogtreecommitdiff
path: root/Remote/Helper
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-02 16:47:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-02 16:59:07 -0400
commitd162d2f7735dceda7645e1e3ec347cbd8625b748 (patch)
tree90d991e84e83955233131285ca74a96698127ebd /Remote/Helper
parent81b339034e8871f211ede2cf3bdb7319ad16caed (diff)
convert glacier to new ChunkedEncryptable API (but do not support chunking)
Chunking would complicate the assistant's code that checks when a pending retrieval of a key from glacier is done. It would perhaps be nice to support it to allow resuming, but not right now. Converting to the new API still simplifies the code.
Diffstat (limited to 'Remote/Helper')
-rw-r--r--Remote/Helper/ChunkedEncryptable.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/Remote/Helper/ChunkedEncryptable.hs b/Remote/Helper/ChunkedEncryptable.hs
index 1267f5b59..e60771551 100644
--- a/Remote/Helper/ChunkedEncryptable.hs
+++ b/Remote/Helper/ChunkedEncryptable.hs
@@ -22,6 +22,7 @@ module Remote.Helper.ChunkedEncryptable (
storeKeyDummy,
retreiveKeyFileDummy,
chunkedEncryptableRemote,
+ encryptableRemote,
module X
) where
@@ -32,7 +33,7 @@ import Crypto
import Config.Cost
import Utility.Metered
import Remote.Helper.Chunked as X
-import Remote.Helper.Encryptable as X
+import Remote.Helper.Encryptable as X hiding (encryptableRemote)
import Annex.Content
import Annex.Exception
@@ -90,14 +91,18 @@ storeKeyDummy _ _ _ = return False
retreiveKeyFileDummy :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
retreiveKeyFileDummy _ _ _ _ = return False
+type RemoteModifier = RemoteConfig -> Preparer Storer -> Preparer Retriever -> Remote -> Remote
+
-- Modifies a base Remote to support both chunking and encryption.
-chunkedEncryptableRemote
- :: RemoteConfig
- -> Preparer Storer
- -> Preparer Retriever
- -> Remote
- -> Remote
-chunkedEncryptableRemote c preparestorer prepareretriever baser = encr
+chunkedEncryptableRemote :: RemoteModifier
+chunkedEncryptableRemote c = chunkedEncryptableRemote' (chunkConfig c) c
+
+-- Modifies a base Remote to support encryption, but not chunking.
+encryptableRemote :: RemoteModifier
+encryptableRemote = chunkedEncryptableRemote' NoChunks
+
+chunkedEncryptableRemote' :: ChunkConfig -> RemoteModifier
+chunkedEncryptableRemote' chunkconfig c preparestorer prepareretriever baser = encr
where
encr = baser
{ storeKey = \k _f p -> cip >>= storeKeyGen k p
@@ -113,7 +118,6 @@ chunkedEncryptableRemote c preparestorer prepareretriever baser = encr
(extractCipher c)
}
cip = cipherKey c
- chunkconfig = chunkConfig c
gpgopts = getGpgEncParams encr
safely a = catchNonAsyncAnnex a (\e -> warning (show e) >> return False)