Refactored approach to ensure the request context is set appropriately
This commit is contained in:
parent
550f6f4d61
commit
e9554562bb
|
@ -298,9 +298,6 @@ function getContextDB(key, opts) {
|
|||
break
|
||||
}
|
||||
|
||||
//If the appId is specified, override context
|
||||
toUseAppId = opts?.appId ? opts?.appId : toUseAppId
|
||||
|
||||
db = dangerousGetDB(toUseAppId, opts)
|
||||
try {
|
||||
cls.setOnContext(key, db)
|
||||
|
|
|
@ -49,6 +49,7 @@ const {
|
|||
getAppDB,
|
||||
getProdAppDB,
|
||||
updateAppId,
|
||||
doInAppContext,
|
||||
} = require("@budibase/backend-core/context")
|
||||
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
||||
import { quotas } from "@budibase/pro"
|
||||
|
@ -340,6 +341,7 @@ export const update = async (ctx: any) => {
|
|||
const data = await updateAppPackage(ctx.request.body, ctx.params.appId)
|
||||
ctx.status = 200
|
||||
ctx.body = data
|
||||
console.log(JSON.stringify(data))
|
||||
}
|
||||
|
||||
export const updateClient = async (ctx: any) => {
|
||||
|
@ -502,7 +504,8 @@ export const sync = async (ctx: any, next: any) => {
|
|||
}
|
||||
|
||||
const updateAppPackage = async (appPackage: any, appId: any) => {
|
||||
const db = getAppDB({ appId })
|
||||
return doInAppContext(appId, async () => {
|
||||
const db = getAppDB()
|
||||
const application = await db.get(DocumentTypes.APP_METADATA)
|
||||
|
||||
const newAppPackage = { ...application, ...appPackage }
|
||||
|
@ -518,6 +521,7 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
|
|||
// remove any cached metadata, so that it will be updated
|
||||
await appCache.invalidateAppMetadata(appId)
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
const createEmptyAppPackage = async (ctx: any, app: any) => {
|
||||
|
|
Loading…
Reference in New Issue