Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions exes/MirrorClient.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}

module Main (main) where

-- stdlib
Expand Down Expand Up @@ -212,8 +214,9 @@ mirrorPackage verbosity opts sourceRepo targetRepo pkginfo = do
notifyResponse (GetPackageFailed theError pkgid)
Nothing -> do
notifyResponse GetPackageOk
liftIO $ sanitiseTarball verbosity (stateDir opts) locTgz
uploadPackage targetRepo (mirrorUploaders opts) pkginfo locCab locTgz
mirrorHandle (\(e :: SomeException) -> liftIO $ putStrLn $ "An error occurred: " <> show e) $ do
liftIO $ sanitiseTarball verbosity (stateDir opts) locTgz
uploadPackage targetRepo (mirrorUploaders opts) pkginfo locCab locTgz

removeTempFiles :: MirrorSession ()
removeTempFiles = liftIO $ handle ignoreDoesNotExist $ do
Expand Down
6 changes: 6 additions & 0 deletions src/Distribution/Client/Mirror/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Distribution.Client.Mirror.Session (
, Unlift(..)
, askUnlift
, mirrorFinally
, mirrorHandle
-- * Errors
, MirrorError(..)
, Entity(..)
Expand Down Expand Up @@ -222,6 +223,11 @@ mirrorFinally a b = do
run <- askUnlift
liftIO $ unlift run a `finally` unlift run b

mirrorHandle :: Exception e => (e -> MirrorSession a) -> MirrorSession a -> MirrorSession a
mirrorHandle k m = do
run <- askUnlift
liftIO $ handle (\e -> unlift run $ k e) $ unlift run m

mirrorAskHttpLib :: MirrorSession Sec.HttpLib
mirrorAskHttpLib = MirrorSession $ do
MirrorInternalEnv{..} <- ask
Expand Down
Loading