summaryrefslogtreecommitdiff
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
parent94aa6b42b5bc5c37c7017fb3493010a56a9d211e (diff)
add tmp flag parameter to retrieveKeyFile
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Get.hs2
-rw-r--r--Command/Move.hs2
-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
-rw-r--r--Types/Remote.hs4
12 files changed, 29 insertions, 27 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index aec29a39b..77e189f43 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -65,7 +65,7 @@ performRemote key file backend numcopies remote = withTmp key $ \tmpfile -> do
showNote err
stop
Right True -> do
- copied <- Remote.retrieveKeyFile remote key tmpfile
+ copied <- Remote.retrieveKeyFile remote key True tmpfile
if copied then go True (Just tmpfile) else go False Nothing
Right False -> go False Nothing
where
diff --git a/Command/Get.hs b/Command/Get.hs
index 5d032e13c..7f5c08a7e 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -72,7 +72,7 @@ getKeyFile key file = do
else return True
docopy r continue = do
showAction $ "from " ++ Remote.name r
- copied <- Remote.retrieveKeyFile r key file
+ copied <- Remote.retrieveKeyFile r key False file
if copied
then return True
else continue
diff --git a/Command/Move.hs b/Command/Move.hs
index 2f2cd1b5d..003ca27b8 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -131,7 +131,7 @@ fromPerform src move key = moveLock move key $ do
then handle move True
else do
showAction $ "from " ++ Remote.name src
- ok <- getViaTmp key $ Remote.retrieveKeyFile src key
+ ok <- getViaTmp key $ Remote.retrieveKeyFile src key False
handle move ok
where
handle _ False = stop -- failed
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"
diff --git a/Types/Remote.hs b/Types/Remote.hs
index 216b34857..d524ea2ca 100644
--- a/Types/Remote.hs
+++ b/Types/Remote.hs
@@ -43,8 +43,8 @@ data RemoteA a = Remote {
cost :: Int,
-- Transfers a key to the remote.
storeKey :: Key -> a Bool,
- -- retrieves a key's contents to a file
- retrieveKeyFile :: Key -> FilePath -> a Bool,
+ -- retrieves a key's contents to a file (possibly a tmp file)
+ retrieveKeyFile :: Key -> Bool -> FilePath -> a Bool,
-- removes a key's contents
removeKey :: Key -> a Bool,
-- Checks if a key is present in the remote; if the remote