From 5fb63dd5812027f12503f469267c5c1c80f2f015 Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Sun, 9 Sep 2018 17:11:50 +0200 Subject: [PATCH 1/2] Catch IOError in discover functions --- src/Lib.hs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Lib.hs b/src/Lib.hs index b7dad24..f5ffc11 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -99,10 +99,13 @@ runRomeWithOptions runRomeWithOptions (RomeOptions options romefilePath verbose) romeVersion = do absoluteRomefilePath <- liftIO $ absolutizePath romefilePath case options of - Utils utilsPayload -> runUtilsCommand options absoluteRomefilePath verbose romeVersion - otherCommad -> runUDCCommand options absoluteRomefilePath verbose romeVersion + Utils utilsPayload -> + runUtilsCommand options absoluteRomefilePath verbose romeVersion + otherCommad -> + runUDCCommand options absoluteRomefilePath verbose romeVersion -runUtilsCommand :: RomeCommand -> FilePath -> Bool -> RomeVersion -> RomeMonad () +runUtilsCommand + :: RomeCommand -> FilePath -> Bool -> RomeVersion -> RomeMonad () runUtilsCommand command absoluteRomefilePath verbose romeVersion = case command of Utils _ -> do @@ -1075,15 +1078,18 @@ filterAccordingToListMode Commands.Present = filter _isAvailable -- | then if not found the region is read via `Configuration.getS3ConfigFile` -- | looking at the _AWS_PROFILE_ environment variable -- | or falling back to _default_ profile. -discoverRegion :: MonadIO m => ExceptT String m AWS.Region +discoverRegion :: (MonadIO m, MonadCatch m) => ExceptT String m AWS.Region discoverRegion = do envRegion <- liftIO $ maybeToEither "No env variable AWS_REGION found. " <$> lookupEnv "AWS_REGION" - f <- getS3ConfigFile profile <- liftIO $ lookupEnv "AWS_PROFILE" - let eitherText = ExceptT . return $ envRegion >>= AWS.fromText . T.pack - eitherText <|> getRegionFromFile f (fromMaybe "default" profile) + let eitherEnvRegion = ExceptT . return $ envRegion >>= AWS.fromText . T.pack + let + eitherFileRegion = + (getS3ConfigFile >>= flip getRegionFromFile (fromMaybe "default" profile)) + `catch` \(e :: IOError) -> ExceptT . return . Left . show $ e + eitherEnvRegion <|> eitherFileRegion @@ -1103,7 +1109,7 @@ getRegionFromFile f profile = fromFile f $ \file -> ExceptT . return $ do -- | then if not found the endpoint is read via `Configuration.getS3ConfigFile` -- | looking at the _AWS_PROFILE_ environment variable -- | or falling back to _default_ profile. -discoverEndpoint :: MonadIO m => ExceptT String m URL +discoverEndpoint :: (MonadIO m, MonadCatch m) => ExceptT String m URL discoverEndpoint = do maybeString <- liftIO $ lookupEnv "AWS_ENDPOINT" let envEndpointURL = @@ -1111,9 +1117,14 @@ discoverEndpoint = do $ maybeString >>= importURL profile <- liftIO $ lookupEnv "AWS_PROFILE" - let fileEndpointURL = liftIO getS3ConfigFile + let + fileEndPointURL = + ( getS3ConfigFile >>= flip getEndpointFromFile (fromMaybe "default" profile) - (ExceptT . return $ envEndpointURL) <|> fileEndpointURL + ) + `catch` \(e :: IOError) -> ExceptT . return . Left . show $ e + (ExceptT . return $ envEndpointURL) <|> fileEndPointURL + From e6a6c2cf9738970654dedeb4e17bf32e88b982b2 Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Sun, 9 Sep 2018 17:13:29 +0200 Subject: [PATCH 2/2] Bump Version --- Rome.cabal | 2 +- Rome.podspec | 2 +- app/Main.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rome.cabal b/Rome.cabal index dbbb2a4..4fdc6d1 100644 --- a/Rome.cabal +++ b/Rome.cabal @@ -1,5 +1,5 @@ name: Rome -version: 0.17.1.49 +version: 0.17.2.50 synopsis: A cache for Carthage description: Please see README.md homepage: https://github.com/blender/Rome diff --git a/Rome.podspec b/Rome.podspec index 67a7550..a2a2fbf 100644 --- a/Rome.podspec +++ b/Rome.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Rome' - s.version = '0.17.1.49' + s.version = '0.17.2.50' s.summary = 'A cache tool for Carthage' s.homepage = 'https://github.com/blender/Rome' s.source = { :http => "#{s.homepage}/releases/download/v#{s.version}/rome.zip" } diff --git a/app/Main.hs b/app/Main.hs index ced9bc2..27681ed 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -10,7 +10,7 @@ import System.Exit romeVersion :: RomeVersion -romeVersion = (0, 17, 1, 49) +romeVersion = (0, 17, 2, 50)