From 46b2f910e5fff035d18604d7642906e40a85dd3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 7 Feb 2023 16:21:36 +0100 Subject: [PATCH] #717: ensure relevant folders are always (re-)cached when lists are cached --- lib/metadataTypes/List.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/metadataTypes/List.js b/lib/metadataTypes/List.js index 475aa2db3..eda7145c4 100644 --- a/lib/metadataTypes/List.js +++ b/lib/metadataTypes/List.js @@ -53,21 +53,23 @@ class List extends MetadataType { */ static async retrieveForCache() { const results = await this.retrieve(); - if (!cache.getCache()?.folder) { - const subTypeArr = [ - 'list', - 'mysubs', - 'suppression_list', - 'publication', - 'contextual_suppression_list', - ]; - Util.logger.debug('folders not cached but required for list'); - Util.logger.info(' - Caching dependent Metadata: folder'); - Util.logSubtypes(subTypeArr); - Folder.client = this.client; - Folder.buObject = this.buObject; - Folder.properties = this.properties; - const result = await Folder.retrieveForCache(null, subTypeArr); + const subTypeArr = [ + 'list', + 'mysubs', + 'suppression_list', + 'publication', + 'contextual_suppression_list', + ]; + Util.logger.debug('folders not cached but required for list'); + Util.logger.info(' - Caching dependent Metadata: folder'); + Util.logSubtypes(subTypeArr); + Folder.client = this.client; + Folder.buObject = this.buObject; + Folder.properties = this.properties; + const result = await Folder.retrieveForCache(null, subTypeArr); + if (cache.getCache()?.folder) { + cache.mergeMetadata('folder', result.metadata); + } else { cache.setMetadata('folder', result.metadata); } for (const metadataEntry in results.metadata) {