diff --git a/services/history-v1/api/controllers/projects.js b/services/history-v1/api/controllers/projects.js index 5ae74cb6da..b5c3b629a9 100644 --- a/services/history-v1/api/controllers/projects.js +++ b/services/history-v1/api/controllers/projects.js @@ -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() }) diff --git a/services/history-v1/storage/lib/chunk_store/mongo.js b/services/history-v1/storage/lib/chunk_store/mongo.js index d84e7a8327..26c1bc48ec 100644 --- a/services/history-v1/storage/lib/chunk_store/mongo.js +++ b/services/history-v1/storage/lib/chunk_store/mongo.js @@ -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( { diff --git a/services/history-v1/test/acceptance/js/storage/support/cleanup.js b/services/history-v1/test/acceptance/js/storage/support/cleanup.js index 55829bef13..632cc96c04 100644 --- a/services/history-v1/test/acceptance/js/storage/support/cleanup.js +++ b/services/history-v1/test/acceptance/js/storage/support/cleanup.js @@ -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(