Browse Source

evict packages from cache on SaveBackend

gh-pages
Michael Shanks 7 years ago
parent
commit
ca6c3d182a
  1. 2
      packages/builder/src/builderStore/store/backend.js
  2. 1
      packages/server/middleware/routers.js
  3. 18
      packages/server/utilities/createAppPackage.js
  4. 8
      packages/server/utilities/masterAppInternal.js

2
packages/builder/src/builderStore/store/backend.js

@ -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]
}

1
packages/server/middleware/routers.js

@ -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 => {

18
packages/server/utilities/createAppPackage.js

@ -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))]
}

8
packages/server/utilities/masterAppInternal.js

@ -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,
}
}

Loading…
Cancel
Save