feat(xo-server-audit/_uploadLastHash): check integrity sequentially (#5250)

- implementation is simpler
- stop on first error
This commit is contained in:
badrAZ 2020-09-17 09:35:42 +02:00 committed by GitHub
parent 14ab694804
commit 8a98b6b012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -35,5 +35,6 @@
>
> In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-server-audit patch
- xo-vmdk-to-vhd patch
- xo-web minor

View File

@ -335,16 +335,18 @@ class AuditXoPlugin {
}
// check the integrity of all stored hashes
integrityCheckSuccess = await Promise.all(
hashes.map((oldest, key) =>
oldest !== lastHash
? this._checkIntegrity({ oldest, newest: hashes[key + 1] })
: true
)
).then(
() => true,
() => false
)
try {
for (let i = 0; i < hashes.length - 1; ++i) {
await this._checkIntegrity({
oldest: hashes[i],
newest: hashes[i + 1],
})
}
integrityCheckSuccess = true
} catch (_) {
integrityCheckSuccess = false
}
}
// generate a valid fingerprint of all stored records in case of a failure integrity check