1
0
Fork 0
mirror of synced 2024-06-16 09:25:12 +12:00

Adding a mechanism for disabling cron jobs when an app is unpublished.

This commit is contained in:
mike12345567 2021-11-17 16:28:52 +00:00
parent 402a16f387
commit 494e042dd8
2 changed files with 13 additions and 0 deletions

View file

@ -46,6 +46,7 @@ const {
const { getTenantId, isMultiTenant } = require("@budibase/auth/tenancy")
const { syncGlobalUsers } = require("./user")
const { app: appCache } = require("@budibase/auth/cache")
const { cleanupAutomations } = require("../../automations/utils")
const URL_REGEX_SLASH = /\/|\\/g
@ -319,6 +320,9 @@ exports.delete = async ctx => {
if (!env.isTest() && !ctx.query.unpublish) {
await deleteApp(ctx.params.appId)
}
if (ctx.query.unpublish) {
await cleanupAutomations(ctx.params.appId)
}
// make sure the app/role doesn't stick around after the app has been deleted
await removeAppFromUserRoles(ctx, ctx.params.appId)
await appCache.invalidateAppMetadata(ctx.params.appId)

View file

@ -163,3 +163,12 @@ exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
}
return newAuto
}
/**
* When removing an app/unpublishing it need to make sure automations are cleaned up (cron).
* @param appId {string} the app that is being removed.
* @return {Promise<void>} clean is complete if this succeeds.
*/
exports.cleanupAutomations = async appId => {
await exports.disableAllCrons(appId)
}