mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 19:54:47 +00:00
transactional refactoring
This commit is contained in:
@@ -86,12 +86,7 @@ getAppsManifestR = do
|
|||||||
let pruned = case osVersion of
|
let pruned = case osVersion of
|
||||||
Nothing -> manifest
|
Nothing -> manifest
|
||||||
Just av -> AppManifest . HM.mapMaybe (filterOsRecommended av) . unAppManifest $ manifest
|
Just av -> AppManifest . HM.mapMaybe (filterOsRecommended av) . unAppManifest $ manifest
|
||||||
withServiceTimestamps <-
|
withServiceTimestamps <- fmap AppManifest . HM.traverseWithKey (addFileTimestamp' appsDir) . unAppManifest $ pruned
|
||||||
fmap AppManifest
|
|
||||||
. HM.traverseWithKey (const pure {-addFileTimestamp' appsDir-}
|
|
||||||
)
|
|
||||||
. unAppManifest
|
|
||||||
$ pruned
|
|
||||||
pure . TypedContent "application/x-yaml" . toContent . Yaml.encode $! withServiceTimestamps
|
pure . TypedContent "application/x-yaml" . toContent . Yaml.encode $! withServiceTimestamps
|
||||||
where
|
where
|
||||||
addFileTimestamp' :: (MonadHandler m, MonadIO m) => FilePath -> AppIdentifier -> StoreApp -> m StoreApp
|
addFileTimestamp' :: (MonadHandler m, MonadIO m) => FilePath -> AppIdentifier -> StoreApp -> m StoreApp
|
||||||
@@ -185,22 +180,21 @@ recordMetrics appId rootDir appVersion = do
|
|||||||
Just x -> pure x
|
Just x -> pure x
|
||||||
pure (sa, vi)
|
pure (sa, vi)
|
||||||
-- lazy load app at requested version if it does not yet exist to automatically transfer from using apps.yaml
|
-- lazy load app at requested version if it does not yet exist to automatically transfer from using apps.yaml
|
||||||
sa <- runDB $ fetchApp appId'
|
runDB $ do
|
||||||
(appKey, versionKey) <- case sa of
|
sa <- fetchApp appId'
|
||||||
Nothing -> do
|
(appKey, versionKey) <- case sa of
|
||||||
appKey' <- runDB $ createApp appId' storeApp >>= errOnNothing status500 "duplicate app created"
|
Nothing -> do
|
||||||
versionKey' <- runDB $ createAppVersion appKey' versionInfo >>= errOnNothing
|
appKey' <- createApp appId' storeApp >>= errOnNothing status500 "duplicate app created"
|
||||||
status500
|
versionKey' <- createAppVersion appKey' versionInfo
|
||||||
"duplicate app version created"
|
>>= errOnNothing status500 "duplicate app version created"
|
||||||
pure (appKey', versionKey')
|
pure (appKey', versionKey')
|
||||||
Just a -> do
|
Just a -> do
|
||||||
let appKey' = entityKey a
|
let appKey' = entityKey a
|
||||||
existingVersion <- runDB $ fetchAppVersion appVersion appKey'
|
existingVersion <- fetchAppVersion appVersion appKey'
|
||||||
case existingVersion of
|
case existingVersion of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
appVersion' <- runDB $ createAppVersion appKey' versionInfo >>= errOnNothing
|
appVersion' <- createAppVersion appKey' versionInfo
|
||||||
status500
|
>>= errOnNothing status500 "duplicate app version created"
|
||||||
"duplicate app version created"
|
pure (appKey', appVersion')
|
||||||
pure (appKey', appVersion')
|
Just v -> pure (appKey', entityKey v)
|
||||||
Just v -> pure (appKey', entityKey v)
|
createMetric appKey versionKey
|
||||||
runDB $ createMetric appKey versionKey
|
|
||||||
|
|||||||
Reference in New Issue
Block a user