From 71d23498c8d34630eb73018c85bde509d25d2d74 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 22 Aug 2023 12:50:17 +0100 Subject: [PATCH] Added missing await and folder existance check while removing pending storage folders --- package-lock.json | 4 ++-- package.json | 2 +- src/service/pending-storage-service.js | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index a6b688d824..df11932a33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.13+hotfix.1", + "version": "6.0.13+hotfix.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.13+hotfix.1", + "version": "6.0.13+hotfix.2", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index f4f0f19f15..4b38948566 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.0.13+hotfix.1", + "version": "6.0.13+hotfix.2", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/service/pending-storage-service.js b/src/service/pending-storage-service.js index 1fa64b2ebd..ebcd84f262 100644 --- a/src/service/pending-storage-service.js +++ b/src/service/pending-storage-service.js @@ -73,7 +73,7 @@ class PendingStorageService { `Removing cached assertion for ual: ${ual} operation id: ${operationId} from file in ${repository} pending storage`, ); - const pendingAssertionPath = this.fileService.getPendingStorageDocumentPath( + const pendingAssertionPath = await this.fileService.getPendingStorageDocumentPath( repository, blockchain, contract, @@ -83,11 +83,17 @@ class PendingStorageService { await this.fileService.removeFile(pendingAssertionPath); const pendingStorageFolderPath = this.fileService.getParentDirectory(pendingAssertionPath); - const otherPendingAssertions = await this.fileService.readDirectory( + const pendingStorageFolderExists = await this.fileService.pathExists( pendingStorageFolderPath, ); - if (otherPendingAssertions.length === 0) { - await this.fileService.removeFolder(pendingStorageFolderPath); + + if (pendingStorageFolderExists) { + const otherPendingAssertions = await this.fileService.readDirectory( + pendingStorageFolderPath, + ); + if (otherPendingAssertions.length === 0) { + await this.fileService.removeFolder(pendingStorageFolderPath); + } } }