From 2dddfa7255329c67bdc57929119589ee6a7f60c0 Mon Sep 17 00:00:00 2001 From: timdeluxe <5765175+timdeluxe@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:00:21 +0100 Subject: [PATCH 1/3] fix: More resistance againts empty json blocks or properties --- src/commands/cleanup.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/commands/cleanup.ts b/src/commands/cleanup.ts index 35f4647..d25b8e1 100644 --- a/src/commands/cleanup.ts +++ b/src/commands/cleanup.ts @@ -189,7 +189,10 @@ export default class extends Command { } } ) - output.push(...response.data.items) + // do not push empty items + if(Object.keys(response.data.items).length) { + output.push(...response.data.items) + } this.logger.debug(`page ${i} and token = +++${response.data.continuationToken}+++`) if (response.data.continuationToken != null) { continuationToken = response.data.continuationToken @@ -208,17 +211,20 @@ export default class extends Command { const components: Array = [] const paths: Array = [] for (let item of output) { - let trimmedPath : string = item.assets[0].path.split("/").slice(0, pathDepth).join("/") - components.push(new Component() - .withDate(item.assets[0].lastModified) - .withId(item.id) - .withVersion(item.version) - .withPath(trimmedPath) - ) - if (!paths.includes(trimmedPath)) { - paths.push(trimmedPath) + // skip if first asset has no path + if(item.assets[0].hasOwnProperty('path')) { + let trimmedPath: string = item.assets[0].path.split("/").slice(0, pathDepth).join("/") + components.push(new Component() + .withDate(item.assets[0].lastModified) + .withId(item.id) + .withVersion(item.version) + .withPath(trimmedPath) + ) + if (!paths.includes(trimmedPath)) { + paths.push(trimmedPath) + } + this.logger.debug(JSON.stringify(item.version)) } - this.logger.debug(JSON.stringify(item.version)) } /** From 4ed26ad9504930196e5f412f9b9ee0d2494af34a Mon Sep 17 00:00:00 2001 From: timdeluxe <5765175+timdeluxe@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:38:21 +0100 Subject: [PATCH 2/3] fix: More resistance againts empty json blocks or properties --- src/commands/cleanup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/cleanup.ts b/src/commands/cleanup.ts index d25b8e1..c6da4d1 100644 --- a/src/commands/cleanup.ts +++ b/src/commands/cleanup.ts @@ -190,7 +190,7 @@ export default class extends Command { } ) // do not push empty items - if(Object.keys(response.data.items).length) { + if(Object.keys(response.data.items).length > 0) { output.push(...response.data.items) } this.logger.debug(`page ${i} and token = +++${response.data.continuationToken}+++`) From 5e9d2d692422e0ba6e8775a3257e30d7c27eb33e Mon Sep 17 00:00:00 2001 From: timdeluxe <5765175+timdeluxe@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:25:24 +0100 Subject: [PATCH 3/3] fix: More resistance againts empty json blocks or properties --- src/commands/cleanup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/cleanup.ts b/src/commands/cleanup.ts index c6da4d1..db71579 100644 --- a/src/commands/cleanup.ts +++ b/src/commands/cleanup.ts @@ -212,7 +212,7 @@ export default class extends Command { const paths: Array = [] for (let item of output) { // skip if first asset has no path - if(item.assets[0].hasOwnProperty('path')) { + if(item.assets.length > 0 && item.assets[0].path) { let trimmedPath: string = item.assets[0].path.split("/").slice(0, pathDepth).join("/") components.push(new Component() .withDate(item.assets[0].lastModified)