mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 19:54:47 +00:00
more dynamic flow
This commit is contained in:
@@ -78,21 +78,20 @@ getApp rootDir ext@(Extension appId) = do
|
|||||||
determineEvent exists (extension ext) filePath appVersion
|
determineEvent exists (extension ext) filePath appVersion
|
||||||
where
|
where
|
||||||
determineEvent :: FileExistence -> String -> FilePath -> AppVersion -> HandlerFor AgentCtx TypedContent
|
determineEvent :: FileExistence -> String -> FilePath -> AppVersion -> HandlerFor AgentCtx TypedContent
|
||||||
-- for system files
|
|
||||||
determineEvent Existent "" fp _ = do
|
|
||||||
sz <- liftIO $ fileSize <$> getFileStatus fp
|
|
||||||
addHeader "Content-Length" (show sz)
|
|
||||||
respondSource typePlain $ CB.sourceFile fp .| awaitForever sendChunkBS
|
|
||||||
-- for app files
|
-- for app files
|
||||||
determineEvent Existent "s9pk" fp av = do
|
determineEvent Existent "s9pk" fp av = do
|
||||||
_ <- recordMetrics appId rootDir av
|
_ <- recordMetrics appId rootDir av
|
||||||
sz <- liftIO $ fileSize <$> getFileStatus fp
|
chunkIt fp
|
||||||
addHeader "Content-Length" (show sz)
|
-- for png, system, etc
|
||||||
respondSource typePlain $ CB.sourceFile fp .| awaitForever sendChunkBS
|
determineEvent Existent _ fp _ = chunkIt fp
|
||||||
-- for png files
|
|
||||||
determineEvent Existent _ _ _ = notFound
|
|
||||||
determineEvent NonExistent _ _ _ = notFound
|
determineEvent NonExistent _ _ _ = notFound
|
||||||
|
|
||||||
|
chunkIt :: FilePath -> HandlerFor AgentCtx TypedContent
|
||||||
|
chunkIt fp = do
|
||||||
|
sz <- liftIO $ fileSize <$> getFileStatus fp
|
||||||
|
addHeader "Content-Length" (show sz)
|
||||||
|
respondSource typePlain $ CB.sourceFile fp .| awaitForever sendChunkBS
|
||||||
|
|
||||||
recordMetrics :: String -> FilePath -> AppVersion -> HandlerFor AgentCtx ()
|
recordMetrics :: String -> FilePath -> AppVersion -> HandlerFor AgentCtx ()
|
||||||
recordMetrics appId rootDir appVersion = do
|
recordMetrics appId rootDir appVersion = do
|
||||||
let appId' = T.pack appId
|
let appId' = T.pack appId
|
||||||
|
|||||||
Reference in New Issue
Block a user