summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-04 03:36:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-04 03:36:39 -0400
commit7ba79cfb8c5c2a0fcb1472ab67bb777999e8e88a (patch)
tree361d18e7f4f42e811f2d48473012f8c3daaec0ff /Remote
parent46383140015fb607ba7d9c7bf5a3c2c435dfb548 (diff)
thread through original key to retrieveEnctypted
Allows showing progress bar for this last case of the directory special remote.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs4
-rw-r--r--Remote/Directory.hs13
-rw-r--r--Remote/Helper/Encryptable.hs4
-rw-r--r--Remote/Hook.hs4
-rw-r--r--Remote/Rsync.hs4
-rw-r--r--Remote/S3.hs4
6 files changed, 17 insertions, 16 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index a4f43a3f3..4ac91e945 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -129,8 +129,8 @@ retrieve buprepo k f = do
retrieveCheap :: BupRepo -> Key -> FilePath -> Annex Bool
retrieveCheap _ _ _ = return False
-retrieveEncrypted :: BupRepo -> (Cipher, Key) -> FilePath -> Annex Bool
-retrieveEncrypted buprepo (cipher, enck) f = do
+retrieveEncrypted :: BupRepo -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
+retrieveEncrypted buprepo (cipher, enck) _ f = do
let params = bupParams "join" buprepo [Param $ show enck]
liftIO $ catchBoolIO $ do
(pid, h) <- hPipeFrom "bup" $ toCommand params
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index 40e6dc72d..e23891e5a 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -237,12 +237,13 @@ retrieve d chunksize k f = metered k $ \meterupdate ->
(L.concat <$> mapM L.readFile files)
return True
-retrieveEncrypted :: FilePath -> ChunkSize -> (Cipher, Key) -> FilePath -> Annex Bool
-retrieveEncrypted d chunksize (cipher, enck) f =
- liftIO $ withStoredFiles chunksize d enck $ \files -> catchBoolIO $ do
- withDecryptedContent cipher (L.concat <$> mapM L.readFile files) $
- L.writeFile f
- return True
+retrieveEncrypted :: FilePath -> ChunkSize -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
+retrieveEncrypted d chunksize (cipher, enck) k f = metered k $ \meterupdate ->
+ liftIO $ withStoredFiles chunksize d enck $ \files ->
+ catchBoolIO $ do
+ withDecryptedContent cipher (L.concat <$> mapM L.readFile files) $
+ meteredWriteFile meterupdate f
+ return True
retrieveCheap :: FilePath -> ChunkSize -> Key -> FilePath -> Annex Bool
retrieveCheap _ (Just _) _ _ = return False -- no cheap retrieval for chunks
diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs
index 0569cb555..bcecb30cc 100644
--- a/Remote/Helper/Encryptable.hs
+++ b/Remote/Helper/Encryptable.hs
@@ -40,7 +40,7 @@ encryptionSetup c =
encryptableRemote
:: Maybe RemoteConfig
-> ((Cipher, Key) -> Key -> Annex Bool)
- -> ((Cipher, Key) -> FilePath -> Annex Bool)
+ -> ((Cipher, Key) -> Key -> FilePath -> Annex Bool)
-> Remote
-> Remote
encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
@@ -58,7 +58,7 @@ encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
(`storeKeyEncrypted` k)
retrieve k f = cip k >>= maybe
(retrieveKeyFile r k f)
- (`retrieveKeyFileEncrypted` f)
+ (\enck -> retrieveKeyFileEncrypted enck k f)
retrieveCheap k f = cip k >>= maybe
(retrieveKeyFileCheap r k f)
(\_ -> return False)
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index c7d710f19..b37d5e215 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -114,8 +114,8 @@ retrieve h k f = runHook h "retrieve" k (Just f) $ return True
retrieveCheap :: String -> Key -> FilePath -> Annex Bool
retrieveCheap _ _ _ = return False
-retrieveEncrypted :: String -> (Cipher, Key) -> FilePath -> Annex Bool
-retrieveEncrypted h (cipher, enck) f = withTmp enck $ \tmp ->
+retrieveEncrypted :: String -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
+retrieveEncrypted h (cipher, enck) _ f = withTmp enck $ \tmp ->
runHook h "retrieve" enck (Just tmp) $ liftIO $ catchBoolIO $ do
withDecryptedContent cipher (L.readFile tmp) $ L.writeFile f
return True
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index 54fb890ca..577ea0b04 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -119,8 +119,8 @@ retrieveCheap o k f = do
then retrieve o k f
else return False
-retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> FilePath -> Annex Bool
-retrieveEncrypted o (cipher, enck) f = withTmp enck $ \tmp -> do
+retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
+retrieveEncrypted o (cipher, enck) _ f = withTmp enck $ \tmp -> do
res <- retrieve o enck tmp
if res
then liftIO $ catchBoolIO $ do
diff --git a/Remote/S3.hs b/Remote/S3.hs
index 523edef65..a688ffcf3 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -161,8 +161,8 @@ retrieve r k f = s3Action r False $ \(conn, bucket) -> do
retrieveCheap :: Remote -> Key -> FilePath -> Annex Bool
retrieveCheap _ _ _ = return False
-retrieveEncrypted :: Remote -> (Cipher, Key) -> FilePath -> Annex Bool
-retrieveEncrypted r (cipher, enck) f = s3Action r False $ \(conn, bucket) -> do
+retrieveEncrypted :: Remote -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
+retrieveEncrypted r (cipher, enck) _ f = s3Action r False $ \(conn, bucket) -> do
res <- liftIO $ getObject conn $ bucketKey r bucket enck
case res of
Right o -> liftIO $