mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
clean up logic for recording metrics
This commit is contained in:
@@ -71,15 +71,22 @@ getApp rootDir ext@(Extension appId) = do
|
|||||||
case getSpecifiedAppVersion spec appVersions of
|
case getSpecifiedAppVersion spec appVersions of
|
||||||
Nothing -> notFound
|
Nothing -> notFound
|
||||||
Just (RegisteredAppVersion (appVersion, filePath)) -> do
|
Just (RegisteredAppVersion (appVersion, filePath)) -> do
|
||||||
exists <- liftIO $ doesFileExist filePath
|
|
||||||
let isApp = isInfixOf "apps" rootDir
|
let isApp = isInfixOf "apps" rootDir
|
||||||
if isApp then toTypedContent <$> recordMetrics appId rootDir appVersion
|
exists <- liftIO $ doesFileExist filePath
|
||||||
else if exists
|
determineEvent exists isApp filePath appVersion
|
||||||
then do
|
where
|
||||||
sz <- liftIO $ fileSize <$> getFileStatus filePath
|
determineEvent True False fp _ = do
|
||||||
addHeader "Content-Length" (show sz)
|
sz <- liftIO $ fileSize <$> getFileStatus fp
|
||||||
respondSource typePlain $ CB.sourceFile filePath .| awaitForever sendChunkBS
|
addHeader "Content-Length" (show sz)
|
||||||
else notFound
|
respondSource typePlain $ CB.sourceFile fp .| awaitForever sendChunkBS
|
||||||
|
determineEvent True True fp av = do
|
||||||
|
_ <- recordMetrics appId rootDir av
|
||||||
|
sz <- liftIO $ fileSize <$> getFileStatus fp
|
||||||
|
addHeader "Content-Length" (show sz)
|
||||||
|
respondSource typePlain $ CB.sourceFile fp .| awaitForever sendChunkBS
|
||||||
|
determineEvent False _ _ _ = notFound
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
errOnNothing :: MonadHandler m => Status -> Text -> Maybe a -> m a
|
errOnNothing :: MonadHandler m => Status -> Text -> Maybe a -> m a
|
||||||
errOnNothing status res entity = case entity of
|
errOnNothing status res entity = case entity of
|
||||||
|
|||||||
Reference in New Issue
Block a user