Explorar o código

Merge pull request #22648 from overleaf/ar-store-backup-blobs-by-history-id

Use historyId when constructing path for backup

GitOrigin-RevId: 954576b509d5e78511b5008fb7d74e0bc5fa45fd
Andrew Rumble hai 1 ano
pai
achega
2262d03a21
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  1. 4 4
      services/history-v1/storage/lib/backupBlob.mjs

+ 4 - 4
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<void>}
  */
-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) {