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.
This commit is contained in:
parent
711c154561
commit
94aa6b42b5
1 changed files with 10 additions and 1 deletions
|
@ -19,6 +19,8 @@ import Remote.Helper.Special
|
||||||
import Remote.Helper.Encryptable
|
import Remote.Helper.Encryptable
|
||||||
import Crypto
|
import Crypto
|
||||||
import Utility.RsyncFile
|
import Utility.RsyncFile
|
||||||
|
import Utility.CopyFile
|
||||||
|
import Utility.FileMode
|
||||||
|
|
||||||
type RsyncUrl = String
|
type RsyncUrl = String
|
||||||
|
|
||||||
|
@ -103,13 +105,20 @@ storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do
|
||||||
rsyncSend o enck tmp
|
rsyncSend o enck tmp
|
||||||
|
|
||||||
retrieve :: RsyncOpts -> Key -> FilePath -> Annex Bool
|
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
|
rsyncRemote o
|
||||||
-- use inplace when retrieving to support resuming
|
-- use inplace when retrieving to support resuming
|
||||||
[ Param "--inplace"
|
[ Param "--inplace"
|
||||||
, Param u
|
, Param u
|
||||||
, Param f
|
, 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 :: RsyncOpts -> (Cipher, Key) -> FilePath -> Annex Bool
|
||||||
retrieveEncrypted o (cipher, enck) f = withTmp enck $ \tmp -> do
|
retrieveEncrypted o (cipher, enck) f = withTmp enck $ \tmp -> do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue