From 726ba287b19abb4e9c0900b701785424217bb4cf Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 17 Sep 2020 10:07:32 +0200 Subject: [PATCH] chore(xo-server-audit/_uploadLastHash): simplify conditions --- packages/xo-server-audit/src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/xo-server-audit/src/index.js b/packages/xo-server-audit/src/index.js index f5703a07a..059a50286 100644 --- a/packages/xo-server-audit/src/index.js +++ b/packages/xo-server-audit/src/index.js @@ -325,12 +325,12 @@ class AuditXoPlugin { const chain = await xo.audit.getLastChain() - let lastHash, integrityCheckSuccess + let lastValidHash if (chain !== null) { const hashes = chain.hashes - lastHash = hashes[hashes.length - 1] + lastValidHash = hashes[hashes.length - 1] - if (lastHash === lastRecordId) { + if (lastValidHash === lastRecordId) { return } @@ -349,16 +349,16 @@ class AuditXoPlugin { throw error } - integrityCheckSuccess = false + lastValidHash = undefined } } // generate a valid fingerprint of all stored records in case of a failure integrity check const { oldest, newest, error } = await this._generateFingerprint({ - oldest: integrityCheckSuccess ? lastHash : undefined, + oldest: lastValidHash, }) - if (chain === null || !integrityCheckSuccess || error !== undefined) { + if (lastValidHash === undefined || error !== undefined) { await xo.audit.startNewChain({ oldest, newest }) } else { await xo.audit.extendLastChain({ oldest, newest })