From 2262d03a219ab55c580d51a4b09f1b8a82320368 Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Mon, 23 Dec 2024 15:00:11 +0000 Subject: [PATCH] Merge pull request #22648 from overleaf/ar-store-backup-blobs-by-history-id Use historyId when constructing path for backup GitOrigin-RevId: 954576b509d5e78511b5008fb7d74e0bc5fa45fd --- services/history-v1/storage/lib/backupBlob.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/history-v1/storage/lib/backupBlob.mjs b/services/history-v1/storage/lib/backupBlob.mjs index 310f3d3430..fb65bf6575 100644 --- a/services/history-v1/storage/lib/backupBlob.mjs +++ b/services/history-v1/storage/lib/backupBlob.mjs @@ -30,15 +30,15 @@ function recordBackupConclusion(status, reason = 'none') { /** * Performs the actual upload of the blob to the backup storage. * - * @param {string} projectId - The project ID of the project the blob belongs to (should have been converted from a postgres ID already if necessary) + * @param {string} historyId - The history ID of the project the blob belongs to * @param {Blob} blob - The blob being uploaded * @param {string} path - The path to the file to upload (should have been stored on disk already) * @return {Promise} */ -export async function uploadBlobToBackup(projectId, blob, path) { +export async function uploadBlobToBackup(historyId, blob, path) { const md5 = Crypto.createHash('md5') await Stream.promises.pipeline(fs.createReadStream(path), md5) - const key = makeProjectKey(projectId, blob.getHash()) + const key = makeProjectKey(historyId, blob.getHash()) const persistor = await backupPersistor.forProject(projectBlobsBucket, key) await persistor.sendStream( projectBlobsBucket, @@ -147,7 +147,7 @@ export async function backupBlob(historyId, blob, tmpPath) { try { logger.debug({ projectId, hash }, 'Starting blob backup') - await uploadBlobToBackup(projectId, blob, tmpPath) + await uploadBlobToBackup(historyId, blob, tmpPath) await storeBlobBackup(projectId, hash) recordBackupConclusion('success') } catch (error) {