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:
@@ -79,23 +79,12 @@ function getBackend(projectId) {
|
||||
}
|
||||
|
||||
async function makeBlobForFile(pathname) {
|
||||
async function getByteLengthOfFile() {
|
||||
const stat = await fs.promises.stat(pathname)
|
||||
return stat.size
|
||||
}
|
||||
|
||||
async function getHashOfFile(blob) {
|
||||
const stream = fs.createReadStream(pathname)
|
||||
const hash = await blobHash.fromStream(blob.getByteLength(), stream)
|
||||
return hash
|
||||
}
|
||||
|
||||
const blob = new Blob()
|
||||
const byteLength = await getByteLengthOfFile()
|
||||
blob.setByteLength(byteLength)
|
||||
const hash = await getHashOfFile(blob)
|
||||
blob.setHash(hash)
|
||||
return blob
|
||||
const { size: byteLength } = await fs.promises.stat(pathname)
|
||||
const hash = await blobHash.fromStream(
|
||||
byteLength,
|
||||
fs.createReadStream(pathname)
|
||||
)
|
||||
return new Blob(hash, byteLength)
|
||||
}
|
||||
|
||||
async function getStringLengthOfFile(byteLength, pathname) {
|
||||
|
||||
Reference in New Issue
Block a user