summaryrefslogtreecommitdiff
path: root/Remote/Rsync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-20 13:23:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-20 13:23:11 -0400
commit61dbad505d648f13394018c31ce2d718c175007e (patch)
tree96f087d5ec3e3eab6cf45b5a7d49cfb2b0dfa7f7 /Remote/Rsync.hs
parente96726caa31fd76413b450790860611f71d13915 (diff)
fsck --from remote --fast
Avoids expensive file transfers, at the expense of checking file size and/or contents. Required some reworking of the remote code.
Diffstat (limited to 'Remote/Rsync.hs')
-rw-r--r--Remote/Rsync.hs26
1 files changed, 16 insertions, 10 deletions
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index a1722fe17..8de6ba6a7 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -48,6 +48,7 @@ gen r u c = do
name = Git.repoDescribe r,
storeKey = store o,
retrieveKeyFile = retrieve o,
+ retrieveKeyFileCheap = retrieveCheap o,
removeKey = remove o,
hasKey = checkPresent r o,
hasKeyCheap = False,
@@ -102,19 +103,24 @@ 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 -> Bool -> FilePath -> Annex Bool
-retrieve o k tmp f = untilTrue (rsyncUrls o k) $ \u -> do
- when tmp $ preseedTmp k f
- rsyncRemote o
- -- use inplace when retrieving to support resuming
- [ Param "--inplace"
- , Param u
- , Param f
- ]
+retrieve :: RsyncOpts -> Key -> FilePath -> Annex Bool
+retrieve o k f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o
+ -- use inplace when retrieving to support resuming
+ [ Param "--inplace"
+ , Param u
+ , Param f
+ ]
+
+retrieveCheap :: RsyncOpts -> Key -> FilePath -> Annex Bool
+retrieveCheap o k f = do
+ ok <- preseedTmp k f
+ if ok
+ then retrieve o k f
+ else return False
retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> FilePath -> Annex Bool
retrieveEncrypted o (cipher, enck) f = withTmp enck $ \tmp -> do
- res <- retrieve o enck False tmp
+ res <- retrieve o enck tmp
if res
then liftIO $ catchBoolIO $ do
withDecryptedContent cipher (L.readFile tmp) $ L.writeFile f