summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-08-27 12:31:50 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-08-27 12:31:50 -0400
commit6e750764b7d30d9cb0684cdaadd79ec091a4fda6 (patch)
treeadcc1c2dac4c1b5ad7a941546250e0931a45c5fc /Utility
parentf82da1d9dca0712cdd87e3fc0ed8a2c2e2440228 (diff)
The wget command will now be used in preference to curl, if available.
Got tired of curl's various ugly progress bars.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Url.hs24
1 files changed, 17 insertions, 7 deletions
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