diff --git a/Command/Fsck.hs b/Command/Fsck.hs index aec29a39b8..77e189f436 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 5d032e13c4..7f5c08a7e6 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 2f2cd1b5d6..003ca27b86 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 37f3e02e09..9a20d9e60b 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 23265dabc9..9705d58435 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 7964074496..5dae3334ec 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 3abea7bc6a..ad99c3092e 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 6c4a044ac9..88124133aa 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 eeb116675f..b4ff3d6f17 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 bef89b5539..b879448244 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 4d6348e596..6db3429ebe 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 216b34857d..d524ea2ca5 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