summaryrefslogtreecommitdiff
path: root/Backend/URL.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-19 01:19:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-19 01:19:56 -0400
commitc7664588f81fe27b3e88d49523ef3c483ac6481a (patch)
treee0cc5dc2f24773a5076f973af38f01ef47f29003 /Backend/URL.hs
parent15986f01d1fd565da151dcb08697e21a94fc9037 (diff)
use safesystem
Diffstat (limited to 'Backend/URL.hs')
-rw-r--r--Backend/URL.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Backend/URL.hs b/Backend/URL.hs
index 5c1fd74c9..c9b6ab6df 100644
--- a/Backend/URL.hs
+++ b/Backend/URL.hs
@@ -3,9 +3,11 @@
module Backend.URL (backend) where
+import Control.Exception
import Control.Monad.State (liftIO)
import Data.String.Utils
import System.Cmd
+import System.Cmd.Utils
import System.Exit
import TypeInternals
@@ -36,9 +38,10 @@ downloadUrl :: Key -> FilePath -> Annex Bool
downloadUrl key file = do
showNote "downloading"
liftIO $ putStrLn "" -- make way for curl progress bar
- result <- liftIO $ rawSystem "curl" ["-#", "-o", file, url]
- if (result == ExitSuccess)
- then return True
- else return False
+ result <- liftIO $ (try curl::IO (Either SomeException ()))
+ case result of
+ Left err -> return False
+ Right succ -> return True
where
+ curl = safeSystem "curl" ["-#", "-o", file, url]
url = join ":" $ drop 1 $ split ":" $ show key