[history-v1] Disable backups on CE/SP (#25591)

Disables backup when `backupStore` is not present,
as it's the case for CE/SP

GitOrigin-RevId: a920f041c639e599084fa97d2ef2643a01da70e3
This commit is contained in:
Miguel Serrano
2025-05-19 11:54:39 +02:00
committed by Copybot
parent d7ef7f0399
commit 85533a36e9
3 changed files with 15 additions and 5 deletions

View File

@@ -255,11 +255,13 @@ async function createProjectBlob(req, res, next) {
const blobStore = new BlobStore(projectId)
const newBlob = await blobStore.putFile(tmpPath)
try {
const { backupBlob } = await import('../../storage/lib/backupBlob.mjs')
await backupBlob(projectId, newBlob, tmpPath)
} catch (error) {
logger.warn({ error, projectId, hash }, 'Failed to backup blob')
if (config.has('backupStore')) {
try {
const { backupBlob } = await import('../../storage/lib/backupBlob.mjs')
await backupBlob(projectId, newBlob, tmpPath)
} catch (error) {
logger.warn({ error, projectId, hash }, 'Failed to backup blob')
}
}
res.status(HTTPStatus.CREATED).end()
})

View File

@@ -3,6 +3,7 @@
const { ObjectId, ReadPreference, MongoError } = require('mongodb')
const { Chunk } = require('overleaf-editor-core')
const OError = require('@overleaf/o-error')
const config = require('config')
const assert = require('../assert')
const mongodb = require('../mongodb')
const { ChunkVersionConflictError } = require('./errors')
@@ -259,6 +260,9 @@ async function updateProjectRecord(
earliestChangeTimestamp,
mongoOpts = {}
) {
if (!config.has('backupStore')) {
return
}
// record the end version against the project
await mongodb.projects.updateOne(
{

View File

@@ -64,6 +64,10 @@ async function clearBucket(name) {
let s3PersistorForBackupCleanup
async function cleanupBackup() {
if (!config.has('backupStore')) {
return
}
// The backupPersistor refuses to delete short prefixes. Use a low-level S3 persistor.
if (!s3PersistorForBackupCleanup) {
const { backupPersistor } = await import(