packages feed

cabal-cache 1.0.1.0 → 1.0.1.1

raw patch · 4 files changed

+36/−5 lines, 4 filesdep ~optparse-applicativePVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependency ranges changed: optparse-applicative

API changes (from Hackage documentation)

+ HaskellWorks.CabalCache.IO.Error: catchErrno :: [Errno] -> IO a -> IO a -> IO a

Files

cabal-cache.cabal view
@@ -1,7 +1,7 @@ cabal-version:          2.2  name:                   cabal-cache-version:                1.0.1.0+version:                1.0.1.1 synopsis:               CI Assistant for Haskell projects description:            CI Assistant for Haskell projects.  Implements package caching. homepage:               https://github.com/haskell-works/cabal-cache
src/App/Commands/SyncFromArchive.hs view
@@ -20,8 +20,9 @@ import Data.Generics.Product.Any        (the) import Data.Maybe import Data.Semigroup                   ((<>))+import Foreign.C.Error ( eXDEV ) import HaskellWorks.CabalCache.AppError-import HaskellWorks.CabalCache.IO.Error (exceptWarn, maybeToExcept)+import HaskellWorks.CabalCache.IO.Error (exceptWarn, maybeToExcept, catchErrno) import HaskellWorks.CabalCache.Location ((<.>), (</>)) import HaskellWorks.CabalCache.Metadata (loadMetadata) import HaskellWorks.CabalCache.Show@@ -153,7 +154,8 @@                         when confPathExists $ do                           confContents <- liftIO $ LBS.readFile theConfPath                           liftIO $ LBS.writeFile tempConfPath (replace (LBS.toStrict oldStorePath) (C8.pack storePath) confContents)-                          liftIO $ IO.renamePath tempConfPath theConfPath+                          liftIO $ catchErrno [eXDEV] (IO.renameFile tempConfPath theConfPath) (IO.copyFile tempConfPath theConfPath >> IO.removeFile tempConfPath)+                         return True           Nothing -> do             CIO.hPutStrLn IO.stderr $ "Warning: Invalid package id: " <> packageId
src/HaskellWorks/CabalCache/Core.hs view
@@ -94,5 +94,8 @@     }  getLibFiles :: FilePath -> FilePath -> Text -> IO [Library]-getLibFiles relativeLibPath libPath libPrefix =-  fmap (relativeLibPath </>) . filter (List.isPrefixOf (T.unpack libPrefix)) <$> IO.listDirectory libPath+getLibFiles relativeLibPath libPath libPrefix = do+  libExists <- IO.doesDirectoryExist libPath+  if libExists+     then fmap (relativeLibPath </>) . filter (List.isPrefixOf (T.unpack libPrefix)) <$> IO.listDirectory libPath+     else pure []
src/HaskellWorks/CabalCache/IO/Error.hs view
@@ -6,10 +6,20 @@   , exceptWarn   , maybeToExcept   , maybeToExceptM+  , catchErrno   ) where  import Control.Monad.Except+import Foreign.C.Error+  (+    getErrno+  , Errno+  ) import HaskellWorks.CabalCache.AppError+import System.IO.Error+  (+    catchIOError+  )  import qualified HaskellWorks.CabalCache.IO.Console as CIO import qualified System.Exit                        as IO@@ -33,3 +43,19 @@  maybeToExceptM :: Monad m => AppError -> m (Maybe a) -> ExceptT AppError m a maybeToExceptM message = ExceptT . fmap (maybe (Left message) Right)+++-- |Carries out an action, then checks if there is an IOException and+-- a specific errno. If so, then it carries out another action, otherwise+-- it rethrows the error.+catchErrno :: [Errno] -- ^ errno to catch+           -> IO a    -- ^ action to try, which can raise an IOException+           -> IO a    -- ^ action to carry out in case of an IOException and+                      --   if errno matches+           -> IO a+catchErrno en a1 a2 =+  catchIOError a1 $ \e -> do+    errno <- getErrno+    if errno `elem` en+      then a2+      else ioError e