mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-12 04:08:29 +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"
|
outname = root </> "output.hoo"
|
||||||
inputTarKey = toPathPiece snapName <> "/hoogle/orig.tar"
|
inputTarKey = toPathPiece snapName <> "/hoogle/orig.tar"
|
||||||
inputTarUrl = downloadBucketUrl <> "/" <> inputTarKey
|
inputTarUrl = downloadBucketUrl <> "/" <> inputTarKey
|
||||||
outputTarFP = root </> T.unpack inputTarKey
|
|
||||||
-- Fetch the tarball with Hoogle inputs
|
-- Fetch the tarball with Hoogle inputs
|
||||||
req <- parseRequest $ T.unpack inputTarUrl
|
req <- parseRequest $ T.unpack inputTarUrl
|
||||||
env <- asks scEnvAWS
|
env <- asks scEnvAWS
|
||||||
let man = env ^. env_manager
|
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?
|
-- 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
|
createDirectoryIfMissing True $ takeDirectory outputTarFP
|
||||||
withBinaryFileDurableAtomic outputTarFP WriteMode $ \tarHandle ->
|
withBinaryFileDurableAtomic outputTarFP WriteMode $ \tarHandle ->
|
||||||
runConduitRes $ bodyReaderSource (responseBody res) .| sinkHandle 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
|
-- Extract the Hoogle inputs from the tarball into a separate temp dir, then
|
||||||
-- generate the hoogle database.
|
-- generate the hoogle database.
|
||||||
|
case mTarFile of
|
||||||
|
Nothing -> pure Nothing
|
||||||
|
Just outputTarFP -> do
|
||||||
withSystemTempDirectory ("hoogle-" ++ T.unpack (textDisplay snapName)) $ \tmpdir -> do
|
withSystemTempDirectory ("hoogle-" ++ T.unpack (textDisplay snapName)) $ \tmpdir -> do
|
||||||
Any hasRestored <-
|
Any hasRestored <-
|
||||||
runConduitRes $
|
runConduitRes $
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user