From 0b192e98d19e913a5edc8f3c91dddaf3ee78bc6f Mon Sep 17 00:00:00 2001 From: Rashmi Date: Mon, 13 Jan 2025 12:58:17 +0530 Subject: [PATCH] DINC0367584 :Issue with repository Id caching in multitenacy SDM CAP-JS Now its cached based on subdomain and repositoryId combination --- lib/sdm.js | 3 ++- lib/util/index.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/sdm.js b/lib/sdm.js index f16f88d..386a6cd 100644 --- a/lib/sdm.js +++ b/lib/sdm.js @@ -39,8 +39,9 @@ module.exports = class SDMAttachmentsService extends ( async checkRepositoryType(req) { const { repositoryId } = getConfigurations(); + let subdomain = cds.context.user?.tokenInfo?.getPayload()?.ext_attr?.zdn; //check if repository is versionable - let repotype = cache.get(repositoryId) + let repotype = cache.get(repositoryId+"_"+subdomain); let isVersioned; if (repotype == undefined) { const token = await getClientCredentialsToken(this.creds); diff --git a/lib/util/index.js b/lib/util/index.js index 4722483..ca9f8ba 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -70,9 +70,10 @@ function isRepositoryVersioned(repoInfo, repositoryId) { } function saveRepoToCache(repositoryId, type) { - const repoType = cache.get(repositoryId); + let subdomain = cds.context.user?.tokenInfo?.getPayload()?.ext_attr?.zdn; + const repoType = cache.get(repositoryId+"_"+subdomain); if (repoType === undefined) { - cache.set(repositoryId, type, 60 * 60 * 24 * 60); + cache.set((repositoryId+"_"+subdomain), type, 60 * 60 * 24 * 60); } }