mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Warn and continue if orig.tar is 404
This commit is contained in:
parent
cbe4038c12
commit
810e0f3253
@ -858,19 +858,32 @@ createHoogleDB rootDir snapshotId snapName = do
|
||||
outname = root </> "output.hoo"
|
||||
inputTarKey = toPathPiece snapName <> "/hoogle/orig.tar"
|
||||
inputTarUrl = downloadBucketUrl <> "/" <> inputTarKey
|
||||
outputTarFP = root </> T.unpack inputTarKey
|
||||
-- Fetch the tarball with Hoogle inputs
|
||||
req <- parseRequest $ T.unpack inputTarUrl
|
||||
env <- asks scEnvAWS
|
||||
let man = env ^. env_manager
|
||||
withResponseUnliftIO req {decompress = const True} man $ \res -> do
|
||||
mTarFile <- withResponseUnliftIO req {decompress = const True} man $ \res -> do
|
||||
-- FIXME: Catch HttpExceptionRequest and give up on this snapshot?
|
||||
throwErrorStatusCodes req res
|
||||
case responseStatus res of
|
||||
status
|
||||
| status == status200 -> do
|
||||
let outputTarFP = root </> T.unpack inputTarKey
|
||||
createDirectoryIfMissing True $ takeDirectory outputTarFP
|
||||
withBinaryFileDurableAtomic outputTarFP WriteMode $ \tarHandle ->
|
||||
runConduitRes $ bodyReaderSource (responseBody res) .| sinkHandle tarHandle
|
||||
pure $ Just outputTarFP
|
||||
| status == status404 -> do
|
||||
logWarn $ "Input orig.tar is a 404 for " <> display snapName
|
||||
pure Nothing
|
||||
| otherwise ->
|
||||
-- NOW we give up.
|
||||
Nothing <$ throwErrorStatusCodes req res
|
||||
|
||||
-- Extract the Hoogle inputs from the tarball into a separate temp dir, then
|
||||
-- generate the hoogle database.
|
||||
case mTarFile of
|
||||
Nothing -> pure Nothing
|
||||
Just outputTarFP -> do
|
||||
withSystemTempDirectory ("hoogle-" ++ T.unpack (textDisplay snapName)) $ \tmpdir -> do
|
||||
Any hasRestored <-
|
||||
runConduitRes $
|
||||
|
||||
Loading…
Reference in New Issue
Block a user