From d92f186fc4bc34e0999a6e47f15e54717e0ab206 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 29 Oct 2010 14:07:26 -0400 Subject: [PATCH] convert safeSystem to boolSystem to fix ctrl-c handling --- Backend/URL.hs | 8 ++------ GitRepo.hs | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Backend/URL.hs b/Backend/URL.hs index fd55ddf01e..7f0bd66733 100644 --- a/Backend/URL.hs +++ b/Backend/URL.hs @@ -7,7 +7,6 @@ module Backend.URL (backend) where -import Control.Exception import Control.Monad.State (liftIO) import Data.String.Utils import System.Cmd @@ -16,6 +15,7 @@ import System.Exit import TypeInternals import Core +import Utility backend = Backend { name = "URL", @@ -42,10 +42,6 @@ downloadUrl :: Key -> FilePath -> Annex Bool downloadUrl key file = do showNote "downloading" liftIO $ putStrLn "" -- make way for curl progress bar - result <- liftIO $ (try curl::IO (Either SomeException ())) - case result of - Left err -> return False - Right succ -> return True + liftIO $ boolSystem "curl" ["-#", "-o", file, url] where - curl = safeSystem "curl" ["-#", "-o", file, url] url = join ":" $ drop 1 $ split ":" $ show key diff --git a/GitRepo.hs b/GitRepo.hs index fd69ec21ae..b9980826ca 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -35,6 +35,7 @@ module GitRepo ( notInRepo ) where +import Monad (when, unless) import Directory import System import System.Directory @@ -183,10 +184,11 @@ gitCommandLine repo@(Repo { location = Dir d} ) params = ["--git-dir="++d++"/"++(dir repo), "--work-tree="++d] ++ params gitCommandLine repo _ = assertLocal repo $ error "internal" -{- Runs git in the specified repo. -} +{- Runs git in the specified repo, throwing an error if it fails. -} run :: Repo -> [String] -> IO () run repo params = assertLocal repo $ do - safeSystem "git" (gitCommandLine repo params) + ok <- boolSystem "git" (gitCommandLine repo params) + unless (ok) $ error $ "git " ++ (show params) ++ " failed" {- Runs a git subcommand and returns its output. -} pipeRead :: Repo -> [String] -> IO String