1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

evict packages from cache on SaveBackend

This commit is contained in:
Michael Shanks 2020-03-25 12:38:04 +00:00
parent f3a9d138d7
commit 5af53922ed
4 changed files with 24 additions and 5 deletions

View file

@ -183,7 +183,7 @@ export const saveCurrentNode = store => () => {
const defaultIndex = templateApi(state.hierarchy).getNewIndexTemplate(
cloned.parent()
)
defaultIndex.name = `all_${cloned.name}`
defaultIndex.name = `all_${cloned.name}s`
defaultIndex.allowedRecordNodeIds = [cloned.nodeId]
}

View file

@ -171,6 +171,7 @@ module.exports = (config, app) => {
ctx.request.body.appDefinition,
ctx.request.body.accessLevels
)
ctx.master.deleteLatestPackageFromCache(ctx.params.appname)
ctx.response.status = StatusCodes.OK
})
.post("/_builder/api/:appname/pages/:pageName", async ctx => {

View file

@ -5,12 +5,16 @@ const { getRuntimePackageDirectory } = require("../utilities/runtimePackages")
const injectPlugins = require("./injectedPlugins")
const { cwd } = require("process")
const appDefinitionPath = appPath => join(appPath, "appDefinition.json")
const pluginsPath = appPath => join(appPath, "plugins.js")
const accessLevelsPath = appPath => join(appPath, "access_levels.json")
const createAppPackage = (context, appPath) => {
const appDefModule = require(join(appPath, "appDefinition.json"))
const appDefModule = require(appDefinitionPath(appPath))
const pluginsModule = require(join(appPath, "plugins.js"))
const pluginsModule = require(pluginsPath(appPath))
const accessLevels = require(join(appPath, "access_levels.json"))
const accessLevels = require(accessLevelsPath(appPath))
return {
appDefinition: appDefModule,
@ -87,3 +91,11 @@ module.exports.applictionVersionPackage = async (
await injectPlugins(pkg, context.master, appname, instanceKey)
return pkg
}
module.exports.deleteCachedPackage = (context, appname, versionId) => {
const appPath = applictionVersionPath(context, appname, versionId)
delete require.cache[resolve(appDefinitionPath(appPath))]
delete require.cache[resolve(pluginsPath(appPath))]
delete require.cache[resolve(accessLevelsPath(appPath))]
}

View file

@ -11,8 +11,9 @@ const {
masterAppPackage,
applictionVersionPackage,
applictionVersionPublicPaths,
deleteCachedPackage,
} = require("../utilities/createAppPackage")
const { determineVersionId } = require("./runtimePackages")
const { determineVersionId, LATEST_VERSIONID } = require("./runtimePackages")
const isMaster = appname => appname === "_master"
@ -345,6 +346,10 @@ module.exports = async context => {
await bb.recordApi.save(userInMaster)
}
const deleteLatestPackageFromCache = (appname) => {
deleteCachedPackage(context, appname, LATEST_VERSIONID)
}
const listApplications = () => values(applications)
return {
@ -364,5 +369,6 @@ module.exports = async context => {
getFullAccessApiForInstanceId,
getFullAccessApiForMaster,
getApplicationWithInstances,
deleteLatestPackageFromCache,
}
}