summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex/Content.hs18
-rw-r--r--Types/GitConfig.hs2
-rw-r--r--debian/changelog1
-rw-r--r--doc/git-annex.mdwn12
4 files changed, 28 insertions, 5 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index 44e5bb106..5985bf227 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -439,10 +439,20 @@ saveState nocommit = doSideAction $ do
{- Downloads content from any of a list of urls. -}
downloadUrl :: [Url.URLString] -> FilePath -> Annex Bool
-downloadUrl urls file = do
- o <- map Param . annexWebOptions <$> Annex.getGitConfig
- headers <- getHttpHeaders
- liftIO $ anyM (\u -> Url.download u headers o file) urls
+downloadUrl urls file = go =<< annexWebDownloadCommand <$> Annex.getGitConfig
+ where
+ go Nothing = do
+ opts <- map Param . annexWebOptions <$> Annex.getGitConfig
+ headers <- getHttpHeaders
+ liftIO $ anyM (\u -> Url.download u headers opts file) urls
+ go (Just basecmd) = liftIO $ anyM (downloadcmd basecmd) urls
+ downloadcmd basecmd url =
+ boolSystem "sh" [Param "-c", Param $ gencmd basecmd url]
+ <&&> doesFileExist file
+ gencmd basecmd url =
+ replace "%file" (shellEscape file) $
+ replace "%url" (shellEscape url)
+ basecmd
{- Copies a key's content, when present, to a temp file.
- This is used to speed up some rsyncs. -}
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs
index c06e3ec6e..ee818574b 100644
--- a/Types/GitConfig.hs
+++ b/Types/GitConfig.hs
@@ -36,6 +36,7 @@ data GitConfig = GitConfig
, annexHttpHeadersCommand :: Maybe String
, annexAutoCommit :: Bool
, annexWebOptions :: [String]
+ , annexWebDownloadCommand :: Maybe String
, annexCrippledFileSystem :: Bool
, annexLargeFiles :: Maybe String
, coreSymlinks :: Bool
@@ -59,6 +60,7 @@ extractGitConfig r = GitConfig
, annexHttpHeadersCommand = getmaybe (annex "http-headers-command")
, annexAutoCommit = getbool (annex "autocommit") True
, annexWebOptions = getwords (annex "web-options")
+ , annexWebDownloadCommand = getmaybe (annex "web-download-command")
, annexCrippledFileSystem = getbool (annex "crippledfilesystem") False
, annexLargeFiles = getmaybe (annex "largefiles")
, coreSymlinks = getbool "core.symlinks" True
diff --git a/debian/changelog b/debian/changelog
index c0a31ccaa..1549a12ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,7 @@ git-annex (4.20130406) UNRELEASED; urgency=low
* webapp: New --listen= option allows running the webapp on one computer
and connecting to it from another. (Note: Does not yet use HTTPS.)
* webapp: When a repository's group is changed, rescan for transfers.
+ * Added annex.web-download-command setting.
-- Joey Hess <joeyh@debian.org> Sat, 06 Apr 2013 15:24:15 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 83ed78257..933163133 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -966,7 +966,7 @@ Here are all the supported configuration settings.
* `annex.web-options`
Options to use when using wget or curl to download a file from the web.
- (wget is always used in preference to curl if available).
+ (wget is always used in preference to curl if available.)
For example, to force ipv4 only, set it to "-4"
* `annex.http-headers`
@@ -979,6 +979,16 @@ Here are all the supported configuration settings.
If set, the command is run and each line of its output is used as a HTTP
header. This overrides annex.http-headers.
+* `annex.web-download-command`
+
+ Use to specify a command to run to download a file from the web.
+ (The default is to use wget or curl.)
+
+ In the command line, %url is replaced with the url to download,
+ and %file is replaced with the file that it should be saved to.
+ Note that both these values will automatically be quoted, since
+ the command is run in a shell.
+
* `remote.<name>.rsyncurl`
Used by rsync special remotes, this configures