use rsync for all remote file transfers

This commit is contained in:
Joey Hess 2010-12-02 17:45:28 -04:00
parent adad12d337
commit b9320ee1d5
3 changed files with 35 additions and 25 deletions

View file

@ -202,11 +202,7 @@ copyFromRemote r key file
where where
keyloc = annexLocation r key keyloc = annexLocation r key
getlocal = liftIO $ copyFile keyloc file getlocal = liftIO $ copyFile keyloc file
getssh = do getssh = remoteCopyFile r (sshLocation r keyloc) file
exists <- liftIO $ doesFileExist file
if exists && SysConfig.rsync
then rsync r [sshLocation r keyloc, file]
else scp r [sshLocation r keyloc, file]
{- Tries to copy a key's content to a file on a remote. -} {- Tries to copy a key's content to a file on a remote. -}
copyToRemote :: Git.Repo -> Key -> FilePath -> Annex Bool copyToRemote :: Git.Repo -> Key -> FilePath -> Annex Bool
@ -220,26 +216,35 @@ copyToRemote r key file = do
else error "copying to non-ssh repo not supported" else error "copying to non-ssh repo not supported"
where where
putlocal src = liftIO $ copyFile src file putlocal src = liftIO $ copyFile src file
putssh src = scp r [src, sshLocation r file] putssh src = remoteCopyFile r src (sshLocation r file)
sshLocation :: Git.Repo -> FilePath -> FilePath sshLocation :: Git.Repo -> FilePath -> FilePath
sshLocation r file = Git.urlHost r ++ ":" ++ shellEscape file sshLocation r file = Git.urlHost r ++ ":" ++ shellEscape file
{- Runs scp against a specified remote. (Honors annex-scp-options.) -} {- Copys a file from or to a remote, using rsync (when available) or scp. -}
scp :: Git.Repo -> [String] -> Annex Bool remoteCopyFile :: Git.Repo -> String -> String -> Annex Bool
scp r params = do remoteCopyFile r src dest = do
scpoptions <- repoConfig r "scp-options" ""
showProgress -- make way for progress bar showProgress -- make way for progress bar
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params o <- repoConfig r configopt ""
res <- liftIO $ boolSystem cmd $ options ++ words o ++ [src, dest]
{- Runs rsync against a specified remote, resuming any interrupted file if res
- transfer. (Honors annex-rsync-options.) -} then return res
rsync :: Git.Repo -> [String] -> Annex Bool else do
rsync r params = do when rsync $
rsyncoptions <- repoConfig r "rsync-options" "" showLongNote "run git annex again to resume file transfer"
showProgress -- make way for progress bar return res
liftIO $ boolSystem "rsync" $ ["--progress", "-a", "--inplace"] ++ where
words rsyncoptions ++ params cmd
| rsync = "rsync"
| otherwise = "scp"
configopt
| rsync = "rsync-options"
| otherwise = "scp-options"
options
-- inplace makes rsync resume partial files
| rsync = ["-p", "--progress", "--inplace"]
| otherwise = ["-p"]
rsync = SysConfig.rsync
{- Runs a command in a remote, using ssh if necessary. {- Runs a command in a remote, using ssh if necessary.
- (Honors annex-ssh-options.) -} - (Honors annex-ssh-options.) -}

5
debian/changelog vendored
View file

@ -1,7 +1,8 @@
git-annex (0.11) UNRELEASED; urgency=low git-annex (0.11) UNRELEASED; urgency=low
* Rsync will now be used to resume interrupted/failed partial file * If available, rsync will be used for file transfers from remote
transfers from a remote. repositories. This allows resuming interrupted transfers.
* Added remote.annex-rsync-options.
-- Joey Hess <joeyh@debian.org> Thu, 02 Dec 2010 16:54:12 -0400 -- Joey Hess <joeyh@debian.org> Thu, 02 Dec 2010 16:54:12 -0400

View file

@ -258,11 +258,15 @@ Here are all the supported configuration settings.
here. here.
* `remote.<name>.annex-scp-options` -- Options to use when using scp * `remote.<name>.annex-scp-options` -- Options to use when using scp
to or from this repository. For example, to force ipv6, and limit to or from this repository. For example, to force ipv6, and limit
the bandwidth to 100Kbit/s, set it to "-6 -l 100" the bandwidth to 1000Kbit/s, set it to "-6 -l 1000"
* `remote.<name>.annex-ssh-options` -- Options to use when using ssh * `remote.<name>.annex-ssh-options` -- Options to use when using ssh
to talk to this repository. to talk to this repository.
* `annex.scp-options` and `annex.ssh-options` -- Default scp and ssh * `remote.<name>.annex-rsync-options` -- Options to use when using rsync
options to use if a remote does not have specific options. to or from this repository. For example, to force ipv6, and limit
the bandwidth to 100Kbyte/s, set it to "-6 --bwlimit 100"
* `annex.scp-options`, `annex.ssh-options`, `annex.rsync-options` --
Default scp, ssh, and rsync options to use if a remote does not have
specific options.
* `annex.version` -- Automatically maintained, and used to automate upgrades * `annex.version` -- Automatically maintained, and used to automate upgrades
between versions. between versions.