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 @@ -619,6 +619,12 @@ hoistDownloadError e =
619
619
throwM $ DestinationNotDirectory f
620
620
DownloadInvariant a b ->
621
621
throwM $ Invariant (renderDownloadError $ DownloadInvariant a b)
622
+ DownloadAws a ->
623
+ throwM a
624
+ DownloadRunError (WorkerError a) ->
625
+ throwM a
626
+ DownloadRunError (BlowUpError a) ->
627
+ throwM a
622
628
MultipartError (WorkerError a) ->
623
629
throwM a
624
630
MultipartError (BlowUpError a) ->
@@ -700,15 +706,17 @@ downloadRecursiveWithMode mode src dest = do
700
706
Left _ -> pure ()
701
707
Right st -> unless (isDirectory st) . left $ DownloadDestinationNotDirectory dest
702
708
-- Real business starts here.
703
- addrs <- lift $ listRecursively src
704
- mapM_ drWorker addrs
709
+ e <- ask
710
+ bimapEitherT DownloadRunError id . void . newEitherT . liftIO $
711
+ (consume (sinkQueue e (listRecursively' src)) 1 (drWorker e))
705
712
where
706
- drWorker :: Address -> EitherT DownloadError AWS ( )
707
- drWorker addr = do
713
+ drWorker :: Env -> Address -> IO ( Either DownloadError () )
714
+ drWorker env addr = runEitherT . runAWST env DownloadAws $ do
708
715
fpdest <- hoistMaybe (DownloadInvariant addr src) $
709
716
((</>) dest) . T. unpack . unKey <$> removeCommonPrefix src addr
710
717
downloadWithMode mode addr fpdest
711
718
719
+
712
720
downloadRecursive :: Address -> FilePath -> EitherT DownloadError AWS ()
713
721
downloadRecursive =
714
722
downloadRecursiveWithMode Fail
Original file line number Diff line number Diff line change @@ -129,9 +129,13 @@ data DownloadError =
129
129
| DownloadDestinationExists FilePath
130
130
| DownloadDestinationNotDirectory FilePath
131
131
| DownloadInvariant Address Address
132
+ | DownloadAws Error
133
+ | DownloadRunError (RunError DownloadError )
132
134
| MultipartError (RunError Error )
133
135
deriving Show
134
136
137
+ instance Exception DownloadError
138
+
135
139
renderDownloadError :: DownloadError -> Text
136
140
renderDownloadError d =
137
141
case d of
@@ -145,6 +149,10 @@ renderDownloadError d =
145
149
" Remove common prefix invariant: " <>
146
150
" [" <> addressToText b <> " ] is not a common prefix of " <>
147
151
" [" <> addressToText a <> " ]"
152
+ DownloadAws e ->
153
+ " AWS failure during 'download': " <> renderError e
154
+ DownloadRunError r ->
155
+ " Download error: " <> renderRunError r renderDownloadError
148
156
MultipartError r ->
149
157
" Multipart download error: " <> renderRunError r renderError
150
158
You can’t perform that action at this time.
0 commit comments