Rsync will now be used to resume interrupted/failed partial file transfers from a remote.

This commit is contained in:
Joey Hess 2010-12-02 16:55:21 -04:00
parent ade43d8fab
commit 37941184f9
6 changed files with 35 additions and 10 deletions

View file

@ -36,6 +36,7 @@ import Utility
import qualified Core
import Messages
import CopyFile
import qualified SysConfig
{- Human visible list of remotes. -}
list :: [Git.Repo] -> String
@ -199,9 +200,13 @@ copyFromRemote r key file
| Git.repoIsSsh r = getssh
| otherwise = error "copying from non-ssh repo not supported"
where
getlocal = liftIO $ copyFile keyloc file
getssh = scp r [sshLocation r keyloc, file]
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]
{- Tries to copy a key's content to a file on a remote. -}
copyToRemote :: Git.Repo -> Key -> FilePath -> Annex Bool
@ -224,9 +229,18 @@ sshLocation r file = Git.urlHost r ++ ":" ++ shellEscape file
scp :: Git.Repo -> [String] -> Annex Bool
scp r params = do
scpoptions <- repoConfig r "scp-options" ""
showProgress -- make way for scp progress bar
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
{- Runs a command in a remote, using ssh if necessary.
- (Honors annex-ssh-options.) -}
runCmd :: Git.Repo -> String -> [String] -> Annex Bool

View file

@ -20,8 +20,9 @@ tests = [
TestCase "cp -a" "cp_a" $ testCp "-a"
, TestCase "cp -p" "cp_p" $ testCp "-p"
, TestCase "cp --reflink=auto" "cp_reflink_auto" $ testCp "--reflink=auto"
, TestCase "uuid" "uuid" $ requireCommand "uuid" "uuid"
, TestCase "xargs -0" "xargs_0" $ requireCommand "xargs -0" "xargs -0 </dev/null"
, TestCase "uuid" "uuid" $ requireCmd "uuid" "uuid"
, TestCase "xargs -0" "xargs_0" $ requireCmd "xargs -0" "xargs -0 </dev/null"
, TestCase "rsync" "rsync" $ testCmd "rsync --version >/dev/null"
]
tmpDir :: String
@ -33,14 +34,14 @@ testFile = tmpDir ++ "/testfile"
quiet :: String -> String
quiet s = s ++ " >/dev/null 2>&1"
requireCommand :: String -> String -> Test
requireCommand command cmdline = do
requireCmd :: String -> String -> Test
requireCmd c cmdline = do
ret <- testCmd $ quiet cmdline
if ret
then return True
else do
testEnd False
error $ "** the " ++ command ++ " command is required to use git-annex"
error $ "** the " ++ c ++ " command is required to use git-annex"
testCp :: String -> Test
testCp option = testCmd $ quiet $ "cp " ++ option ++ " " ++ testFile ++

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (0.11) UNRELEASED; urgency=low
* Rsync will now be used to resume interrupted/failed partial file
transfers from a remote.
-- Joey Hess <joeyh@debian.org> Thu, 02 Dec 2010 16:54:12 -0400
git-annex (0.10) unstable; urgency=low
* In .gitattributes, the annex.numcopies attribute can be used

4
debian/control vendored
View file

@ -1,7 +1,7 @@
Source: git-annex
Section: utils
Priority: optional
Build-Depends: debhelper (>= 7.0.50), ghc6, libghc6-missingh-dev, libghc6-testpack-dev, ikiwiki, uuid
Build-Depends: debhelper (>= 7.0.50), ghc6, libghc6-missingh-dev, libghc6-testpack-dev, ikiwiki, uuid, rsync
Maintainer: Joey Hess <joeyh@debian.org>
Standards-Version: 3.9.1
Vcs-Git: git://git.kitenet.net/git-annex
@ -10,7 +10,7 @@ Homepage: http://git-annex.branchable.com/
Package: git-annex
Architecture: any
Section: utils
Depends: ${misc:Depends}, ${shlibs:Depends}, git | git-core, uuid, openssh-client
Depends: ${misc:Depends}, ${shlibs:Depends}, git | git-core, uuid, openssh-client, rsync
Description: manage files with git, without checking their contents into git
git-annex allows managing files with git, without checking the file
contents into git. While that may seem paradoxical, it is useful when

View file

@ -5,6 +5,7 @@ To build and use git-annex, you will need:
* MissingH: <http://github.com/jgoerzen/missingh/wiki>
* `uuid`: <http://www.ossp.org/pkg/lib/uuid/>
* `xargs`: <http://savannah.gnu.org/projects/findutils/>
* `rsync` (optional but recommended)
* Then just [[download]] git-annex and run: `make; make install`
([Ikiwiki](http://ikiwiki.info) is needed to build the documentation,

View file

@ -1,2 +1,4 @@
Transferring a file from a ssh:// remote should use rsync to allow resuming
of a prior transfer.
[[done]]