Improve types and export functions we want to use

GitOrigin-RevId: 25fd93214f88c425bee23d43de113cf754f89524
This commit is contained in:
Andrew Rumble
2025-03-27 17:13:51 +00:00
committed by Copybot
parent 3600aa4b75
commit 392037efd6
4 changed files with 10 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ const path = require('node:path')
* after.
*
* @param {string} prefix - prefix for the temporary directory name
* @param {Function} fn - async function to call
* @param {(tmpDir: string) => Promise<void>} fn - async function to call
*/
async function withTmpDir(prefix, fn) {
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), prefix))

View File

@@ -63,7 +63,7 @@ exports.fromString = function blobHashFromString(string) {
* Compute the git blob hash for the content of a file
*
* @param {string} filePath
* @return {string} hexadecimal SHA-1 hash
* @return {Promise<string>} hexadecimal SHA-1 hash
*/
exports.fromFile = function blobHashFromFile(pathname) {
assert.string(pathname, 'blobHash: bad pathname')

View File

@@ -24,6 +24,7 @@ const logger = require('@overleaf/logger')
/** @import { Readable } from 'stream' */
/** @type {Map<string, { blob: core.Blob, demoted: boolean}>} */
const GLOBAL_BLOBS = new Map()
function makeGlobalKey(hash) {
@@ -343,6 +344,11 @@ class BlobStore {
return blob
}
/**
*
* @param {Array<string>} hashes
* @return {Promise<*[]>}
*/
async getBlobs(hashes) {
assert.array(hashes, 'bad hashes')
const nonGlobalHashes = []
@@ -427,6 +433,7 @@ module.exports = {
getProjectBlobsBatch,
loadGlobalBlobs,
makeProjectKey,
makeGlobalKey,
makeBlobForFile,
getStringLengthOfFile,
GLOBAL_BLOBS,

View File

@@ -915,7 +915,7 @@ async function compareBackups(projectId, options) {
const globalBlob = GLOBAL_BLOBS.get(blob.hash)
console.log(
` ✓ Blob ${blob.hash} is a global blob`,
globalBlob.demoted ? '(demoted)' : ''
globalBlob?.demoted ? '(demoted)' : ''
)
continue
}