Merge pull request #10246 from overleaf/jpa-pdf-caching-object-id-back-fill

[web] pdf-caching: double down on back-filling of object-id

GitOrigin-RevId: 751392dc5ed59eb621eca3813040c7b92ef1369e
This commit is contained in:
Jakob Ackermann 2022-11-01 15:22:40 +00:00 committed by Copybot
parent 1a434558d7
commit 6f00659865

View file

@ -125,10 +125,19 @@ function backFillObjectContext(chunk, arrayBuffer) {
return new Uint8Array(arrayBuffer)
}
const { size, objectId } = chunk
const header = Uint8Array.from(objectId)
const fullBuffer = new Uint8Array(size)
fullBuffer.set(header, 0)
fullBuffer.set(new Uint8Array(arrayBuffer), objectId.length)
const sourceBuffer = new Uint8Array(arrayBuffer)
try {
fullBuffer.set(objectId, 0)
fullBuffer.set(sourceBuffer, objectId.byteLength)
} catch (err) {
throw OError.tag(err, 'broken back-filling of object-id', {
objectIdByteLength: objectId.byteLength,
fullBufferByteLength: fullBuffer.byteLength,
arrayBufferByteLength: arrayBuffer.byteLength,
sourceBufferByteLength: sourceBuffer.byteLength,
})
}
return fullBuffer
}