use rsync for all remote file transfers
This commit is contained in:
parent
adad12d337
commit
b9320ee1d5
3 changed files with 35 additions and 25 deletions
45
Remotes.hs
45
Remotes.hs
|
@ -202,11 +202,7 @@ copyFromRemote r key file
|
|||
where
|
||||
keyloc = annexLocation r key
|
||||
getlocal = liftIO $ copyFile keyloc file
|
||||
getssh = do
|
||||
exists <- liftIO $ doesFileExist file
|
||||
if exists && SysConfig.rsync
|
||||
then rsync r [sshLocation r keyloc, file]
|
||||
else scp r [sshLocation r keyloc, file]
|
||||
getssh = remoteCopyFile r (sshLocation r keyloc) file
|
||||
|
||||
{- Tries to copy a key's content to a file on a remote. -}
|
||||
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"
|
||||
where
|
||||
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 r file = Git.urlHost r ++ ":" ++ shellEscape file
|
||||
|
||||
{- Runs scp against a specified remote. (Honors annex-scp-options.) -}
|
||||
scp :: Git.Repo -> [String] -> Annex Bool
|
||||
scp r params = do
|
||||
scpoptions <- repoConfig r "scp-options" ""
|
||||
{- Copys a file from or to a remote, using rsync (when available) or scp. -}
|
||||
remoteCopyFile :: Git.Repo -> String -> String -> Annex Bool
|
||||
remoteCopyFile r src dest = do
|
||||
showProgress -- make way for progress bar
|
||||
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params
|
||||
|
||||
{- Runs rsync against a specified remote, resuming any interrupted file
|
||||
- transfer. (Honors annex-rsync-options.) -}
|
||||
rsync :: Git.Repo -> [String] -> Annex Bool
|
||||
rsync r params = do
|
||||
rsyncoptions <- repoConfig r "rsync-options" ""
|
||||
showProgress -- make way for progress bar
|
||||
liftIO $ boolSystem "rsync" $ ["--progress", "-a", "--inplace"] ++
|
||||
words rsyncoptions ++ params
|
||||
o <- repoConfig r configopt ""
|
||||
res <- liftIO $ boolSystem cmd $ options ++ words o ++ [src, dest]
|
||||
if res
|
||||
then return res
|
||||
else do
|
||||
when rsync $
|
||||
showLongNote "run git annex again to resume file transfer"
|
||||
return res
|
||||
where
|
||||
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.
|
||||
- (Honors annex-ssh-options.) -}
|
||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -1,7 +1,8 @@
|
|||
git-annex (0.11) UNRELEASED; urgency=low
|
||||
|
||||
* Rsync will now be used to resume interrupted/failed partial file
|
||||
transfers from a remote.
|
||||
* If available, rsync will be used for file transfers from 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
|
||||
|
||||
|
|
|
@ -258,11 +258,15 @@ Here are all the supported configuration settings.
|
|||
here.
|
||||
* `remote.<name>.annex-scp-options` -- Options to use when using scp
|
||||
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
|
||||
to talk to this repository.
|
||||
* `annex.scp-options` and `annex.ssh-options` -- Default scp and ssh
|
||||
options to use if a remote does not have specific options.
|
||||
* `remote.<name>.annex-rsync-options` -- Options to use when using rsync
|
||||
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
|
||||
between versions.
|
||||
|
||||
|
|
Loading…
Reference in a new issue