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

View file

@ -20,8 +20,9 @@ tests = [
TestCase "cp -a" "cp_a" $ testCp "-a" TestCase "cp -a" "cp_a" $ testCp "-a"
, TestCase "cp -p" "cp_p" $ testCp "-p" , TestCase "cp -p" "cp_p" $ testCp "-p"
, TestCase "cp --reflink=auto" "cp_reflink_auto" $ testCp "--reflink=auto" , TestCase "cp --reflink=auto" "cp_reflink_auto" $ testCp "--reflink=auto"
, TestCase "uuid" "uuid" $ requireCommand "uuid" "uuid" , TestCase "uuid" "uuid" $ requireCmd "uuid" "uuid"
, TestCase "xargs -0" "xargs_0" $ requireCommand "xargs -0" "xargs -0 </dev/null" , TestCase "xargs -0" "xargs_0" $ requireCmd "xargs -0" "xargs -0 </dev/null"
, TestCase "rsync" "rsync" $ testCmd "rsync --version >/dev/null"
] ]
tmpDir :: String tmpDir :: String
@ -33,14 +34,14 @@ testFile = tmpDir ++ "/testfile"
quiet :: String -> String quiet :: String -> String
quiet s = s ++ " >/dev/null 2>&1" quiet s = s ++ " >/dev/null 2>&1"
requireCommand :: String -> String -> Test requireCmd :: String -> String -> Test
requireCommand command cmdline = do requireCmd c cmdline = do
ret <- testCmd $ quiet cmdline ret <- testCmd $ quiet cmdline
if ret if ret
then return True then return True
else do else do
testEnd False 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 :: String -> Test
testCp option = testCmd $ quiet $ "cp " ++ option ++ " " ++ testFile ++ 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 git-annex (0.10) unstable; urgency=low
* In .gitattributes, the annex.numcopies attribute can be used * In .gitattributes, the annex.numcopies attribute can be used

4
debian/control vendored
View file

@ -1,7 +1,7 @@
Source: git-annex Source: git-annex
Section: utils Section: utils
Priority: optional 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> Maintainer: Joey Hess <joeyh@debian.org>
Standards-Version: 3.9.1 Standards-Version: 3.9.1
Vcs-Git: git://git.kitenet.net/git-annex Vcs-Git: git://git.kitenet.net/git-annex
@ -10,7 +10,7 @@ Homepage: http://git-annex.branchable.com/
Package: git-annex Package: git-annex
Architecture: any Architecture: any
Section: utils 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 Description: manage files with git, without checking their contents into git
git-annex allows managing files with git, without checking the file git-annex allows managing files with git, without checking the file
contents into git. While that may seem paradoxical, it is useful when 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> * MissingH: <http://github.com/jgoerzen/missingh/wiki>
* `uuid`: <http://www.ossp.org/pkg/lib/uuid/> * `uuid`: <http://www.ossp.org/pkg/lib/uuid/>
* `xargs`: <http://savannah.gnu.org/projects/findutils/> * `xargs`: <http://savannah.gnu.org/projects/findutils/>
* `rsync` (optional but recommended)
* Then just [[download]] git-annex and run: `make; make install` * Then just [[download]] git-annex and run: `make; make install`
([Ikiwiki](http://ikiwiki.info) is needed to build the documentation, ([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 Transferring a file from a ssh:// remote should use rsync to allow resuming
of a prior transfer. of a prior transfer.
[[done]]