diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-19 15:49:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-19 15:49:55 -0400 |
commit | 94aa6b42b5bc5c37c7017fb3493010a56a9d211e (patch) | |
tree | 0582c978602d17d79154c4880ef1591c37757929 /Remote | |
parent | 711c15456109f77a04832d8ca0871ce56ffaffe4 (diff) |
optimise fsck --from rsync special remote
When a file is present locally, the remote's version can be rsynced to
a copy of it, which will avoid wasting a lot of bandwidth.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/Rsync.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index c7b60467c..eeb116675 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -19,6 +19,8 @@ import Remote.Helper.Special import Remote.Helper.Encryptable import Crypto import Utility.RsyncFile +import Utility.CopyFile +import Utility.FileMode type RsyncUrl = String @@ -103,13 +105,20 @@ storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do rsyncSend o enck tmp retrieve :: RsyncOpts -> Key -> FilePath -> Annex Bool -retrieve o k f = untilTrue (rsyncUrls o k) $ \u -> +retrieve o k f = untilTrue (rsyncUrls o k) $ \u -> do + unlessM (liftIO $ doesFileExist f) $ whenM (inAnnex k) $ preseed rsyncRemote o -- use inplace when retrieving to support resuming [ Param "--inplace" , Param u , Param f ] + where + -- this speeds up fsck --from + preseed = 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 |