File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -653,6 +653,12 @@ hoistDownloadError e =
653653 throwM $ DestinationNotDirectory f
654654 DownloadInvariant a b ->
655655 throwM $ Invariant (renderDownloadError $ DownloadInvariant a b)
656+ DownloadAws a ->
657+ throwM a
658+ DownloadRunError (WorkerError a) ->
659+ throwM a
660+ DownloadRunError (BlowUpError a) ->
661+ throwM a
656662 MultipartError (WorkerError a) ->
657663 throwM a
658664 MultipartError (BlowUpError a) ->
@@ -734,15 +740,17 @@ downloadRecursiveWithMode mode src dest = do
734740 Left _ -> pure ()
735741 Right st -> unless (isDirectory st) . left $ DownloadDestinationNotDirectory dest
736742 -- Real business starts here.
737- addrs <- lift $ listRecursively src
738- mapM_ drWorker addrs
743+ e <- ask
744+ bimapEitherT DownloadRunError id . void . newEitherT . liftIO $
745+ (consume (sinkQueue e (listRecursively' src)) 1 (drWorker e))
739746 where
740- drWorker :: Address -> EitherT DownloadError AWS ( )
741- drWorker addr = do
747+ drWorker :: Env -> Address -> IO ( Either DownloadError () )
748+ drWorker env addr = runEitherT . runAWST env DownloadAws $ do
742749 fpdest <- hoistMaybe (DownloadInvariant addr src) $
743750 ((</>) dest) . T. unpack . unKey <$> removeCommonPrefix src addr
744751 downloadWithMode mode addr fpdest
745752
753+
746754downloadRecursive :: Address -> FilePath -> EitherT DownloadError AWS ()
747755downloadRecursive =
748756 downloadRecursiveWithMode Fail
Original file line number Diff line number Diff line change @@ -129,9 +129,13 @@ data DownloadError =
129129 | DownloadDestinationExists FilePath
130130 | DownloadDestinationNotDirectory FilePath
131131 | DownloadInvariant Address Address
132+ | DownloadAws Error
133+ | DownloadRunError (RunError DownloadError )
132134 | MultipartError (RunError Error )
133135 deriving Show
134136
137+ instance Exception DownloadError
138+
135139renderDownloadError :: DownloadError -> Text
136140renderDownloadError d =
137141 case d of
@@ -145,6 +149,10 @@ renderDownloadError d =
145149 " Remove common prefix invariant: " <>
146150 " [" <> addressToText b <> " ] is not a common prefix of " <>
147151 " [" <> addressToText a <> " ]"
152+ DownloadAws e ->
153+ " AWS failure during 'download': " <> renderError e
154+ DownloadRunError r ->
155+ " Download error: " <> renderRunError r renderDownloadError
148156 MultipartError r ->
149157 " Multipart download error: " <> renderRunError r renderError
150158
You can’t perform that action at this time.
0 commit comments