summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-19 16:07:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-19 16:07:36 -0400
commit06b0cb6224377fd2ea86e4e209e94a502f92716e (patch)
treeae6f1a631aebbdd18a2aef7ff7ec7299d9214d26 /Remote
parent94aa6b42b5bc5c37c7017fb3493010a56a9d211e (diff)
add tmp flag parameter to retrieveKeyFile
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Bup.hs4
-rw-r--r--Remote/Directory.hs5
-rw-r--r--Remote/Git.hs4
-rw-r--r--Remote/Helper/Encryptable.hs4
-rw-r--r--Remote/Hook.hs4
-rw-r--r--Remote/Rsync.hs17
-rw-r--r--Remote/S3.hs4
-rw-r--r--Remote/Web.hs4
8 files changed, 24 insertions, 22 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 37f3e02e0..9a20d9e60 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -118,8 +118,8 @@ storeEncrypted r buprepo (cipher, enck) k = do
withEncryptedHandle cipher (L.readFile src) $ \h ->
pipeBup params (Just h) Nothing
-retrieve :: BupRepo -> Key -> FilePath -> Annex Bool
-retrieve buprepo k f = do
+retrieve :: BupRepo -> Key -> Bool -> FilePath -> Annex Bool
+retrieve buprepo k _ f = do
let params = bupParams "join" buprepo [Param $ show k]
liftIO $ catchBoolIO $ do
tofile <- openFile f WriteMode
diff --git a/Remote/Directory.hs b/Remote/Directory.hs
index 23265dabc..9705d5843 100644
--- a/Remote/Directory.hs
+++ b/Remote/Directory.hs
@@ -109,8 +109,9 @@ storeHelper d key a = do
preventWrite dir
return ok
-retrieve :: FilePath -> Key -> FilePath -> Annex Bool
-retrieve d k f = liftIO $ withStoredFile d k $ \file -> copyFileExternal file f
+retrieve :: FilePath -> Key -> Bool -> FilePath -> Annex Bool
+retrieve d k _ f = do
+ liftIO $ withStoredFile d k $ \file -> copyFileExternal file f
retrieveEncrypted :: FilePath -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted d (cipher, enck) f =
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 796407449..5dae3334e 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -198,8 +198,8 @@ dropKey r key
]
{- Tries to copy a key's content from a remote's annex to a file. -}
-copyFromRemote :: Git.Repo -> Key -> FilePath -> Annex Bool
-copyFromRemote r key file
+copyFromRemote :: Git.Repo -> Key -> Bool -> FilePath -> Annex Bool
+copyFromRemote r key _ file
| not $ Git.repoIsUrl r = do
params <- rsyncParams r
loc <- liftIO $ gitAnnexLocation key r
diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs
index 3abea7bc6..ad99c3092 100644
--- a/Remote/Helper/Encryptable.hs
+++ b/Remote/Helper/Encryptable.hs
@@ -55,8 +55,8 @@ encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
store k = cip k >>= maybe
(storeKey r k)
(`storeKeyEncrypted` k)
- retrieve k f = cip k >>= maybe
- (retrieveKeyFile r k f)
+ retrieve k t f = cip k >>= maybe
+ (retrieveKeyFile r k t f)
(`retrieveKeyFileEncrypted` f)
withkey a k = cip k >>= maybe (a k) (a . snd)
cip = cipherKey c
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index 6c4a044ac..88124133a 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -106,8 +106,8 @@ storeEncrypted h (cipher, enck) k = withTmp enck $ \tmp -> do
liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp
runHook h "store" enck (Just tmp) $ return True
-retrieve :: String -> Key -> FilePath -> Annex Bool
-retrieve h k f = runHook h "retrieve" k (Just f) $ return True
+retrieve :: String -> Key -> Bool -> FilePath -> Annex Bool
+retrieve h k _ f = runHook h "retrieve" k (Just f) $ return True
retrieveEncrypted :: String -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted h (cipher, enck) f = withTmp enck $ \tmp ->
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index eeb116675..b4ff3d6f1 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -104,9 +104,9 @@ storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do
liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp
rsyncSend o enck tmp
-retrieve :: RsyncOpts -> Key -> FilePath -> Annex Bool
-retrieve o k f = untilTrue (rsyncUrls o k) $ \u -> do
- unlessM (liftIO $ doesFileExist f) $ whenM (inAnnex k) $ preseed
+retrieve :: RsyncOpts -> Key -> Bool -> FilePath -> Annex Bool
+retrieve o k tmp f = untilTrue (rsyncUrls o k) $ \u -> do
+ when tmp $ preseed
rsyncRemote o
-- use inplace when retrieving to support resuming
[ Param "--inplace"
@@ -115,14 +115,15 @@ retrieve o k f = untilTrue (rsyncUrls o k) $ \u -> do
]
where
-- this speeds up fsck --from
- preseed = do
- s <- inRepo $ gitAnnexLocation k
- liftIO $ whenM (copyFileExternal s f) $
- allowWrite f
+ preseed = unlessM (liftIO $ doesFileExist f) $
+ whenM (inAnnex k) $ do
+ s <- inRepo $ gitAnnexLocation k
+ liftIO $ whenM (copyFileExternal s f) $
+ allowWrite f
retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted o (cipher, enck) f = withTmp enck $ \tmp -> do
- res <- retrieve o enck tmp
+ res <- retrieve o enck False tmp
if res
then liftIO $ catchBoolIO $ do
withDecryptedContent cipher (L.readFile tmp) $ L.writeFile f
diff --git a/Remote/S3.hs b/Remote/S3.hs
index bef89b553..b87944824 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -149,8 +149,8 @@ storeHelper (conn, bucket) r k file = do
xheaders = filter isxheader $ M.assocs $ fromJust $ config r
isxheader (h, _) = "x-amz-" `isPrefixOf` h
-retrieve :: Remote -> Key -> FilePath -> Annex Bool
-retrieve r k f = s3Action r False $ \(conn, bucket) -> do
+retrieve :: Remote -> Key -> Bool -> FilePath -> Annex Bool
+retrieve r k _ f = s3Action r False $ \(conn, bucket) -> do
res <- liftIO $ getObject conn $ bucketKey r bucket k
case res of
Right o -> do
diff --git a/Remote/Web.hs b/Remote/Web.hs
index 4d6348e59..6db3429eb 100644
--- a/Remote/Web.hs
+++ b/Remote/Web.hs
@@ -48,8 +48,8 @@ gen r _ _ =
remotetype = remote
}
-downloadKey :: Key -> FilePath -> Annex Bool
-downloadKey key file = get =<< getUrls key
+downloadKey :: Key -> Bool -> FilePath -> Annex Bool
+downloadKey key _ file = get =<< getUrls key
where
get [] = do
warning "no known url"