mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 11:51:57 +00:00
fixes lack of content length in eos image download
This commit is contained in:
@@ -108,6 +108,7 @@ import Network.HTTP.Types ( status400
|
|||||||
)
|
)
|
||||||
import Protolude.Unsafe ( unsafeFromJust )
|
import Protolude.Unsafe ( unsafeFromJust )
|
||||||
import Settings ( AppSettings(registryHostname, resourcesDir) )
|
import Settings ( AppSettings(registryHostname, resourcesDir) )
|
||||||
|
import System.Directory ( getFileSize )
|
||||||
import System.FilePath ( (</>) )
|
import System.FilePath ( (</>) )
|
||||||
import UnliftIO.Async ( concurrently
|
import UnliftIO.Async ( concurrently
|
||||||
, mapConcurrently
|
, mapConcurrently
|
||||||
@@ -124,6 +125,7 @@ import Yesod.Core ( HandlerFor
|
|||||||
, ToTypedContent(..)
|
, ToTypedContent(..)
|
||||||
, TypedContent
|
, TypedContent
|
||||||
, YesodRequest(..)
|
, YesodRequest(..)
|
||||||
|
, addHeader
|
||||||
, getRequest
|
, getRequest
|
||||||
, getsYesod
|
, getsYesod
|
||||||
, logWarn
|
, logWarn
|
||||||
@@ -131,6 +133,7 @@ import Yesod.Core ( HandlerFor
|
|||||||
, respondSource
|
, respondSource
|
||||||
, sendChunkBS
|
, sendChunkBS
|
||||||
, sendResponseStatus
|
, sendResponseStatus
|
||||||
|
, setHeader
|
||||||
, typeOctet
|
, typeOctet
|
||||||
)
|
)
|
||||||
import Yesod.Persist.Core ( YesodPersist(runDB) )
|
import Yesod.Persist.Core ( YesodPersist(runDB) )
|
||||||
@@ -321,6 +324,7 @@ getEosR = do
|
|||||||
Nothing -> sendResponseStatus status404 (NotFoundE [i|EOS version satisfying #{spec}|])
|
Nothing -> sendResponseStatus status404 (NotFoundE [i|EOS version satisfying #{spec}|])
|
||||||
Just r -> do
|
Just r -> do
|
||||||
let imgPath = root </> show r </> "eos.img"
|
let imgPath = root </> show r </> "eos.img"
|
||||||
|
liftIO (getFileSize imgPath) >>= addHeader "Content-Length" . show
|
||||||
respondSource typeOctet (sourceFile imgPath .| awaitForever sendChunkBS)
|
respondSource typeOctet (sourceFile imgPath .| awaitForever sendChunkBS)
|
||||||
|
|
||||||
getVersionLatestR :: Handler VersionLatestRes
|
getVersionLatestR :: Handler VersionLatestRes
|
||||||
|
|||||||
Reference in New Issue
Block a user