Merge pull request #21664 from overleaf/jpa-blob-hash

[overleaf-editor-core] stricter types for Blob interface

GitOrigin-RevId: 8595fce0d5c98074d2313be5a5634e80f92c68b5
This commit is contained in:
Jakob Ackermann
2024-11-08 09:07:05 +00:00
committed by Copybot
parent 122d89a831
commit a3d8caf87b
4 changed files with 18 additions and 34 deletions
@@ -63,20 +63,14 @@ class FileData {
*/
static createLazyFromBlobs(blob, rangesBlob) {
assert.instance(blob, Blob, 'FileData: bad blob')
if (blob.getStringLength() == null) {
return new BinaryFileData(
// TODO(das7pad): see call-sites
// @ts-ignore
blob.getHash(),
blob.getByteLength()
)
const stringLength = blob.getStringLength()
if (stringLength == null) {
return new BinaryFileData(blob.getHash(), blob.getByteLength())
}
return new LazyStringFileData(
// TODO(das7pad): see call-sites
// @ts-ignore
blob.getHash(),
rangesBlob?.getHash(),
blob.getStringLength()
stringLength
)
}
@@ -142,12 +142,8 @@ class StringFileData extends FileData {
trackedChanges: this.trackedChanges.toRaw(),
}
const rangesBlob = await blobStore.putObject(ranges)
// TODO(das7pad): Provide interface that guarantees hash exists?
// @ts-ignore
return { hash: blob.getHash(), rangesHash: rangesBlob.getHash() }
}
// TODO(das7pad): Provide interface that guarantees hash exists?
// @ts-ignore
return { hash: blob.getHash() }
}
}