mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Merge pull request #22648 from overleaf/ar-store-backup-blobs-by-history-id
Use historyId when constructing path for backup GitOrigin-RevId: 954576b509d5e78511b5008fb7d74e0bc5fa45fd
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user