diff options
author | Joey Hess <joey@kitenet.net> | 2011-08-27 12:31:50 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-08-27 12:31:50 -0400 |
commit | 6e750764b7d30d9cb0684cdaadd79ec091a4fda6 (patch) | |
tree | adcc1c2dac4c1b5ad7a941546250e0931a45c5fc | |
parent | f82da1d9dca0712cdd87e3fc0ed8a2c2e2440228 (diff) |
The wget command will now be used in preference to curl, if available.
Got tired of curl's various ugly progress bars.
-rw-r--r-- | Utility.hs | 12 | ||||
-rw-r--r-- | Utility/Url.hs | 24 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | doc/install.mdwn | 2 |
5 files changed, 31 insertions, 10 deletions
diff --git a/Utility.hs b/Utility.hs index 788dc4103..451b1b44f 100644 --- a/Utility.hs +++ b/Utility.hs @@ -15,7 +15,8 @@ module Utility ( dirContains, dirContents, myHomeDir, - catchBool + catchBool, + inPath ) where import IO (bracket) @@ -94,3 +95,12 @@ myHomeDir = do {- Catches IO errors and returns a Bool -} catchBool :: IO Bool -> IO Bool catchBool = flip catch (const $ return False) + +{- Checks if a command is available in PATH. -} +inPath :: String -> IO Bool +inPath command = search =<< getSearchPath + where + search [] = return False + search (d:ds) = do + e <- doesFileExist $ d </> command + if e then return True else search ds diff --git a/Utility/Url.hs b/Utility/Url.hs index f678720ed..6ddeecc14 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -20,6 +20,7 @@ import Network.URI import Types import Messages import Utility.SafeCommand +import Utility type URLString = String @@ -35,15 +36,24 @@ exists url = _ -> return False {- Used to download large files, such as the contents of keys. - - Uses curl program for its progress bar. -} + - Uses wget or curl program for its progress bar. (Wget has a better one, + - so is preferred.) -} download :: URLString -> FilePath -> Annex Bool download url file = do - showOutput -- make way for curl progress bar - -- Uses the -# progress display, because the normal one is very - -- confusing when resuming, showing the remainder to download - -- as the whole file, and not indicating how much percent was - -- downloaded before the resume. - liftIO $ boolSystem "curl" [Params "-L -C - -# -o", File file, File url] + showOutput -- make way for program's progress bar + e <- liftIO $ inPath "wget" + if e + then + liftIO $ boolSystem "wget" + [Params "-c -O", File file, File url] + else + -- Uses the -# progress display, because the normal + -- one is very confusing when resuming, showing + -- the remainder to download as the whole file, + -- and not indicating how much percent was + -- downloaded before the resume. + liftIO $ boolSystem "curl" + [Params "-L -C - -# -o", File file, File url] {- Downloads a small file. -} get :: URLString -> IO String diff --git a/debian/changelog b/debian/changelog index bb06e1fba..54fdbd835 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-annex (3.20110820) UNRELEASED; urgency=low * Set EMAIL when running test suite so that git does not need to be configured first. Closes: #638998 + * The wget command will now be used in preference to curl, if available. -- Joey Hess <joeyh@debian.org> Tue, 23 Aug 2011 13:41:01 -0400 diff --git a/debian/control b/debian/control index 975faf5ea..63488dc68 100644 --- a/debian/control +++ b/debian/control @@ -31,7 +31,7 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, git | git-core, uuid, rsync, - curl, + wget | curl, openssh-client Suggests: graphviz, bup, gnupg Description: manage files with git, without checking their contents into git diff --git a/doc/install.mdwn b/doc/install.mdwn index 49ddd913f..ac521da18 100644 --- a/doc/install.mdwn +++ b/doc/install.mdwn @@ -34,7 +34,7 @@ To build and use git-annex, you will need: (or `uuidgen` from util-linux) * [xargs](http://savannah.gnu.org/projects/findutils/) * [rsync](http://rsync.samba.org/) - * [curl](http://http://curl.haxx.se/) (optional, but recommended) + * [wget](http://www.gnu.org/software/wget/) or [curl](http://http://curl.haxx.se/) (optional, but recommended) * [sha1sum](ftp://ftp.gnu.org/gnu/coreutils/) (optional, but recommended; a sha1 command will also do) * [gpg](http://gnupg.org/) (optional; needed for encryption) |