Skip to content

Commit

Permalink
#988: skip caching assets if run via --refresh flag
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jun 26, 2023
1 parent 7ab2d81 commit 8dba950
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 7 additions & 2 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5496,7 +5496,7 @@ MessageSendActivity MetadataType
* [.preDeployTasks(metadata)](#TriggeredSend.preDeployTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.refresh([keyArr], [checkKey])](#TriggeredSend.refresh) ⇒ <code>Promise.&lt;void&gt;</code>
* [.getKeysForValidTSDs(metadata)](#TriggeredSend.getKeysForValidTSDs) ⇒ <code>Promise.&lt;Array.&lt;string&gt;&gt;</code>
* [.findRefreshableItems()](#TriggeredSend.findRefreshableItems) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.findRefreshableItems([assetLoaded])](#TriggeredSend.findRefreshableItems) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [._refreshItem(key, checkKey)](#TriggeredSend._refreshItem) ⇒ <code>Promise.&lt;boolean&gt;</code>

<a name="TriggeredSend.retrieve"></a>
Expand Down Expand Up @@ -5601,11 +5601,16 @@ helper for [refresh](refresh) that extracts the keys from the TSD item map and e

<a name="TriggeredSend.findRefreshableItems"></a>

### TriggeredSend.findRefreshableItems() ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
### TriggeredSend.findRefreshableItems([assetLoaded]) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
helper for [refresh](refresh) that finds active TSDs on the server and filters it by the same rules that [retrieve](retrieve) is using to avoid refreshing TSDs with broken dependencies

**Kind**: static method of [<code>TriggeredSend</code>](#TriggeredSend)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code> - Promise of TSD item map

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [assetLoaded] | <code>boolean</code> | <code>false</code> | if run after Asset.deploy via --refresh option this will skip caching assets |

<a name="TriggeredSend._refreshItem"></a>

### TriggeredSend.\_refreshItem(key, checkKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
Expand Down
4 changes: 2 additions & 2 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class Asset extends MetadataType {
* @param {TYPE.AssetItem} metadata a single asset
* @param {TYPE.AssetSubType} subType group of similar assets to put in a folder (ie. images)
* @param {string} deployDir directory of deploy files
* @param {boolean} [pathOnly=false] used by getFilesToCommit which does not need the binary file to be actually read
* @param {boolean} [pathOnly] used by getFilesToCommit which does not need the binary file to be actually read
* @returns {Promise.<string>} if found will return the path of the binary file
*/
static async _readExtendedFileFromFS(metadata, subType, deployDir, pathOnly = false) {
Expand Down Expand Up @@ -545,7 +545,7 @@ class Asset extends MetadataType {
TriggeredSend.client = this.client;
try {
// find refreshable TSDs
const tsdObj = (await TriggeredSend.findRefreshableItems()).metadata;
const tsdObj = (await TriggeredSend.findRefreshableItems(true)).metadata;

const tsdCountInitial = Object.keys(tsdObj).length;
const emailCount = legacyIdArr.length;
Expand Down
6 changes: 5 additions & 1 deletion lib/metadataTypes/TriggeredSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ class TriggeredSend extends MetadataType {
/**
* helper for {@link refresh} that finds active TSDs on the server and filters it by the same rules that {@link retrieve} is using to avoid refreshing TSDs with broken dependencies
*
* @param {boolean} [assetLoaded] if run after Asset.deploy via --refresh option this will skip caching assets
* @returns {Promise.<TYPE.MetadataTypeMapObj>} Promise of TSD item map
*/
static async findRefreshableItems() {
static async findRefreshableItems(assetLoaded = false) {
Util.logger.info('Finding refreshable items...');
// cache dependencies to test for broken links
// skip deprecated classic emails here, assuming they cannot be updated and hence are not relevant for {@link refresh}
Expand All @@ -273,6 +274,9 @@ class TriggeredSend extends MetadataType {
list: null,
};
for (const [type, subTypeArr] of Object.entries(requiredCache)) {
if (type === 'asset' && assetLoaded) {
continue;
}
Util.logger.info(` - Caching dependent Metadata: ${type}`);
Util.logSubtypes(subTypeArr);
cacheTypes[type].client = this.client;
Expand Down

0 comments on commit 8dba950

Please sign in to comment.