feat(xo-server-audit): don't save last hash when it doesn't change (#5251)

This commit is contained in:
badrAZ 2020-09-08 14:35:19 +02:00 committed by GitHub
parent d622f7a65c
commit 481adf3a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,6 +318,11 @@ class AuditXoPlugin {
return
}
const lastRecordId = await this._storage.getLastId()
if (lastRecordId === undefined) {
return
}
const chain = await xo.audit.getLastChain()
let lastHash, integrityCheckSuccess
@ -325,6 +330,10 @@ class AuditXoPlugin {
const hashes = chain.hashes
lastHash = hashes[hashes.length - 1]
if (lastHash === lastRecordId) {
return
}
// check the integrity of all stored hashes
integrityCheckSuccess = await Promise.all(
hashes.map((oldest, key) =>