Clearing upp app cache a bit more safely.

This commit is contained in:
mike12345567 2025-03-03 13:11:35 +00:00
parent fe44c467fd
commit 762d28f305
1 changed files with 11 additions and 2 deletions

View File

@ -635,6 +635,11 @@ async function unpublishApp(ctx: UserCtx) {
return result
}
async function invalidateAppCache(appId: string) {
await cache.app.invalidateAppMetadata(dbCore.getDevAppID(appId))
await cache.app.invalidateAppMetadata(dbCore.getProdAppID(appId))
}
async function destroyApp(ctx: UserCtx) {
let appId = ctx.params.appId
appId = dbCore.getProdAppID(appId)
@ -659,12 +664,16 @@ async function destroyApp(ctx: UserCtx) {
}
await removeAppFromUserRoles(ctx, appId)
await cache.app.invalidateAppMetadata(devAppId)
await invalidateAppCache(appId)
return result
}
async function preDestroyApp(ctx: UserCtx) {
const { rows } = await getUniqueRows([ctx.params.appId])
// invalidate the cache immediately in-case they are leading to
// zombie appearing apps
const appId = ctx.params.appId
await invalidateAppCache(appId)
const { rows } = await getUniqueRows([appId])
ctx.rowCount = rows.length
}