mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Improve types and export functions we want to use
GitOrigin-RevId: 25fd93214f88c425bee23d43de113cf754f89524
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user