fix(xva): use a buildless dependency for hashes (#7348)

Native dependencies can have some problems on closed systems

Introduced by 2d047c4fef
This commit is contained in:
Florent BEAUCHAMP 2024-02-01 16:30:57 +01:00 committed by GitHub
parent 838f9a42d1
commit 8461d68d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 14 deletions

View File

@ -1,13 +1,11 @@
import { fromCallback } from 'promise-toolbox'
import { readChunkStrict } from '@vates/read-chunk'
import { XXHash64 } from 'xxhash'
import { xxhash64 } from 'hash-wasm'
async function writeBlock(pack, data, name) {
await fromCallback.call(pack, pack.entry, { name }, data)
const hasher = new XXHash64(0)
hasher.update(data)
// weirdly, ocaml and xxhash return the bytes in reverse order to each other
const hash = hasher.digest().reverse().toString('hex').toUpperCase()
const hash = (await xxhash64(data)).toString('hex').toUpperCase()
await fromCallback.call(pack, pack.entry, { name: `${name}.xxhash` }, Buffer.from(hash, 'utf8'))
}
export default async function addDisk(pack, vhd, basePath) {

View File

@ -17,11 +17,11 @@
},
"dependencies": {
"@vates/read-chunk": "^1.2.0",
"hash-wasm": "^4.11.0",
"lodash.defaultsdeep": "^4.6.1",
"promise-toolbox": "^0.21.0",
"tar-stream": "^3.1.6",
"uuid": "^9.0.0",
"xxhash": "^0.3.0"
"uuid": "^9.0.0"
},
"scripts": {
"postversion": "npm publish --access public"

View File

@ -27,4 +27,6 @@
<!--packages-start-->
- @xen-orchestra/xva patch
<!--packages-end-->

View File

@ -12265,6 +12265,11 @@ hash-sum@^2.0.0:
resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-2.0.0.tgz#81d01bb5de8ea4a214ad5d6ead1b523460b0b45a"
integrity sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==
hash-wasm@^4.11.0:
version "4.11.0"
resolved "https://registry.yarnpkg.com/hash-wasm/-/hash-wasm-4.11.0.tgz#7d1479b114c82e48498fdb1d2462a687d00386d5"
integrity sha512-HVusNXlVqHe0fzIzdQOGolnFN6mX/fqcrSAOcTBXdvzrXVHwTz11vXeKRmkR5gTuwVpvHZEIyKoePDvuAR+XwQ==
hash.js@^1.0.0, hash.js@^1.0.3:
version "1.1.7"
resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42"
@ -16164,7 +16169,7 @@ mute-stream@0.0.8:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
nan@^2.12.1, nan@^2.13.2:
nan@^2.12.1:
version "2.18.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.18.0.tgz#26a6faae7ffbeb293a39660e88a76b82e30b7554"
integrity sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==
@ -23511,13 +23516,6 @@ xtend@~2.1.1:
dependencies:
object-keys "~0.4.0"
xxhash@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/xxhash/-/xxhash-0.3.0.tgz#d20893a62c5b0f7260597dd55859b12a1e02c559"
integrity sha512-1ud2yyPiR1DJhgyF1ZVMt+Ijrn0VNS/wzej1Z8eSFfkNfRPp8abVZNV2u9tYy9574II0ZayZYZgJm8KJoyGLCw==
dependencies:
nan "^2.13.2"
xxhashjs@^0.2.1:
version "0.2.2"
resolved "https://registry.yarnpkg.com/xxhashjs/-/xxhashjs-0.2.2.tgz#8a6251567621a1c46a5ae204da0249c7f8caa9d8"