diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-18 22:49:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-18 22:49:07 -0400 |
commit | 7e9c2f1ef320e01320560eb2e3d92e1bc1bae0aa (patch) | |
tree | 88a9aada9729c9237d786f12548cc138f9574d3c /Remote/S3.hs | |
parent | 8ffd06e588011fd26cd258530b0c05b42b484a0a (diff) |
S3: Added progress display for uploading and downloading.
Diffstat (limited to 'Remote/S3.hs')
-rw-r--r-- | Remote/S3.hs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/Remote/S3.hs b/Remote/S3.hs index 5905f14fc..ca4161c15 100644 --- a/Remote/S3.hs +++ b/Remote/S3.hs @@ -152,26 +152,29 @@ storeHelper (conn, bucket) r k p file = do isxheader (h, _) = "x-amz-" `isPrefixOf` h retrieve :: Remote -> Key -> AssociatedFile -> FilePath -> Annex Bool -retrieve r k _f d = s3Action r False $ \(conn, bucket) -> do - res <- liftIO $ getObject conn $ bucketKey r bucket k - case res of - Right o -> do - liftIO $ L.writeFile d $ obj_data o - return True - Left e -> s3Warning e +retrieve r k _f d = s3Action r False $ \(conn, bucket) -> + metered Nothing k $ \meterupdate -> do + res <- liftIO $ getObject conn $ bucketKey r bucket k + case res of + Right o -> do + liftIO $ meteredWriteFile meterupdate d $ + obj_data o + return True + Left e -> s3Warning e retrieveCheap :: Remote -> Key -> FilePath -> Annex Bool retrieveCheap _ _ _ = return False 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 $ decrypt cipher (feedBytes $ obj_data o) $ - readBytes $ \content -> do - L.writeFile f content - return True - Left e -> s3Warning e +retrieveEncrypted r (cipher, enck) k d = s3Action r False $ \(conn, bucket) -> + metered Nothing k $ \meterupdate -> do + res <- liftIO $ getObject conn $ bucketKey r bucket enck + case res of + Right o -> liftIO $ decrypt cipher (\h -> meteredWrite meterupdate h $ obj_data o) $ + readBytes $ \content -> do + L.writeFile d content + return True + Left e -> s3Warning e remove :: Remote -> Key -> Annex Bool remove r k = s3Action r False $ \(conn, bucket) -> do |