diff --git a/services/history-v1/api/controllers/with_tmp_dir.js b/services/history-v1/api/controllers/with_tmp_dir.js index a9c2e9fb47..2e0737ba69 100644 --- a/services/history-v1/api/controllers/with_tmp_dir.js +++ b/services/history-v1/api/controllers/with_tmp_dir.js @@ -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} fn - async function to call */ async function withTmpDir(prefix, fn) { const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), prefix)) diff --git a/services/history-v1/storage/lib/blob_hash.js b/services/history-v1/storage/lib/blob_hash.js index 6309637d08..10ac64b87b 100644 --- a/services/history-v1/storage/lib/blob_hash.js +++ b/services/history-v1/storage/lib/blob_hash.js @@ -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} hexadecimal SHA-1 hash */ exports.fromFile = function blobHashFromFile(pathname) { assert.string(pathname, 'blobHash: bad pathname') diff --git a/services/history-v1/storage/lib/blob_store/index.js b/services/history-v1/storage/lib/blob_store/index.js index b4a7d1682f..033e288554 100644 --- a/services/history-v1/storage/lib/blob_store/index.js +++ b/services/history-v1/storage/lib/blob_store/index.js @@ -24,6 +24,7 @@ const logger = require('@overleaf/logger') /** @import { Readable } from 'stream' */ +/** @type {Map} */ const GLOBAL_BLOBS = new Map() function makeGlobalKey(hash) { @@ -343,6 +344,11 @@ class BlobStore { return blob } + /** + * + * @param {Array} 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, diff --git a/services/history-v1/storage/scripts/backup.mjs b/services/history-v1/storage/scripts/backup.mjs index 94df24f66d..8cbbadfe12 100644 --- a/services/history-v1/storage/scripts/backup.mjs +++ b/services/history-v1/storage/scripts/backup.mjs @@ -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 }