summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-02 17:45:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-02 17:45:28 -0400
commitb9320ee1d53bfe72b0fbf7e08c927f5b45bbc5c9 (patch)
tree1e18e726c6dbfa6111a50f17fae6591156fd38d6
parentadad12d3374102790cab0cfbb9a5f0721ff88fc9 (diff)
use rsync for all remote file transfers
-rw-r--r--Remotes.hs45
-rw-r--r--debian/changelog5
-rw-r--r--doc/git-annex.mdwn10
3 files changed, 35 insertions, 25 deletions
diff --git a/Remotes.hs b/Remotes.hs
index 6bb67216b..6dc516048 100644
--- a/Remotes.hs
+++ b/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.) -}
diff --git a/debian/changelog b/debian/changelog
index 0bdfbf76a..5a9d332bc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 64ca6a549..63bc11eb7 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -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.