diff --git a/src/commands/protocols/get/sender/local-get-command.js b/src/commands/protocols/get/sender/local-get-command.js index db331825e6..fa1236be33 100644 --- a/src/commands/protocols/get/sender/local-get-command.js +++ b/src/commands/protocols/get/sender/local-get-command.js @@ -17,32 +17,32 @@ class LocalGetCommand extends Command { * @param command */ async execute(command) { - const { operationId, assertionId } = command.data; + const {operationId, assertionId} = command.data; await this.operationIdService.updateOperationIdStatus( operationId, OPERATION_ID_STATUS.GET.GET_LOCAL_START, ); + const assertionExists = await this.tripleStoreModuleManager.assertionExists(`assertion:${assertionId}`); + if (assertionExists) { + const nquads = await this.getService.localGet(assertionId, operationId); - const assertion = await this.getService.localGet(assertionId, operationId); + if (nquads.length) { + await this.operationIdService.cacheOperationIdData(operationId, nquads); + await this.operationIdService.updateOperationIdStatus( + operationId, + OPERATION_ID_STATUS.GET.GET_LOCAL_END, + ); + await this.operationIdService.updateOperationIdStatus( + operationId, + OPERATION_ID_STATUS.GET.GET_END, + ); + await this.operationIdService.updateOperationIdStatus( + operationId, + OPERATION_ID_STATUS.COMPLETED, + ); - if (assertion.length) { - await this.operationIdService.cacheOperationIdData(operationId, { - assertion, - }); - await this.operationIdService.updateOperationIdStatus( - operationId, - OPERATION_ID_STATUS.GET.GET_LOCAL_END, - ); - await this.operationIdService.updateOperationIdStatus( - operationId, - OPERATION_ID_STATUS.GET.GET_END, - ); - await this.operationIdService.updateOperationIdStatus( - operationId, - OPERATION_ID_STATUS.COMPLETED, - ); - - return Command.empty(); + return Command.empty(); + } } await this.operationIdService.updateOperationIdStatus(