summaryrefslogtreecommitdiff
path: root/Remote/S3real.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-27 20:06:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-27 20:23:09 -0400
commite68f128a9bf46c8f4ebe51fcb3b6f63955cadd2e (patch)
tree2102052ed8289efa0e44b4f9269c423753d70983 /Remote/S3real.hs
parent4381ac062fa7cec01476e84a7bd8e154efb8aacd (diff)
rsync special remote
Fully tested and working, including resuming and encryption. (Though not resuming when sending *with* encryption; gpg doesn't produce identical output each time.) Uses same layout as the directory special remote and the .git/annex/objects/ directory.
Diffstat (limited to 'Remote/S3real.hs')
-rw-r--r--Remote/S3real.hs20
1 files changed, 8 insertions, 12 deletions
diff --git a/Remote/S3real.hs b/Remote/S3real.hs
index 07e33368e..2e198f79d 100644
--- a/Remote/S3real.hs
+++ b/Remote/S3real.hs
@@ -19,7 +19,6 @@ import Control.Monad (when)
import Control.Monad.State (liftIO)
import System.Environment
import System.Posix.Files
-import System.Directory
import RemoteClass
import Types
@@ -33,7 +32,7 @@ import Remote.Special
import Remote.Encryptable
import Crypto
import Key
-import Utility
+import Content
remote :: RemoteType Annex
remote = RemoteType {
@@ -108,18 +107,15 @@ store r k = s3Action r False $ \(conn, bucket) -> do
s3Bool res
storeEncrypted :: Remote Annex -> (Cipher, Key) -> Key -> Annex Bool
-storeEncrypted r (cipher, enck) k = s3Action r False $ \(conn, bucket) -> do
- g <- Annex.gitRepo
- let f = gitAnnexLocation g k
+storeEncrypted r (cipher, enck) k = s3Action r False $ \(conn, bucket) ->
-- To get file size of the encrypted content, have to use a temp file.
-- (An alternative would be chunking to to a constant size.)
- let tmp = gitAnnexTmpLocation g enck
- liftIO $ createDirectoryIfMissing True (parentDir tmp)
- liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s
- res <- liftIO $ storeHelper (conn, bucket) r enck tmp
- tmp_exists <- liftIO $ doesFileExist tmp
- when tmp_exists $ liftIO $ removeFile tmp
- s3Bool res
+ withTmp enck $ \tmp -> do
+ g <- Annex.gitRepo
+ let f = gitAnnexLocation g k
+ liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s
+ res <- liftIO $ storeHelper (conn, bucket) r enck tmp
+ s3Bool res
storeHelper :: (AWSConnection, String) -> Remote Annex -> Key -> FilePath -> IO (AWSResult ())
storeHelper (conn, bucket) r k file = do