diff --git a/services/history-v1/api/controllers/projects.js b/services/history-v1/api/controllers/projects.js index 040970faea..2b79beffc6 100644 --- a/services/history-v1/api/controllers/projects.js +++ b/services/history-v1/api/controllers/projects.js @@ -290,7 +290,8 @@ async function getZip(req, res, next) { async function streamZip(snapshot, blobStore, res) { await withTmpDir('get-zip-', async tmpDir => { const tmpFilename = Path.join(tmpDir, 'project.zip') - const archive = new ProjectArchive(snapshot) + const zipTimeoutMs = parseInt(config.get('zipStore.zipTimeoutMs'), 10) + const archive = new ProjectArchive(snapshot, zipTimeoutMs) await archive.writeZip(blobStore, tmpFilename) res.set('Content-Type', 'application/octet-stream') res.set('Content-Disposition', 'attachment; filename=project.zip') diff --git a/services/history-v1/storage/lib/project_archive.js b/services/history-v1/storage/lib/project_archive.js index 8a8e93f1c9..bc06a2d398 100644 --- a/services/history-v1/storage/lib/project_archive.js +++ b/services/history-v1/storage/lib/project_archive.js @@ -21,7 +21,6 @@ const assert = require('./assert') // The maximum safe concurrency appears to be 1. // https://github.com/overleaf/issues/issues/1909 const FETCH_CONCURRENCY = 1 // number of files to fetch at once -const DEFAULT_ZIP_TIMEOUT = 25000 // ms class DownloadError extends OError { constructor(hash) { @@ -49,14 +48,14 @@ class ProjectArchive { /** * @constructor * @param {Snapshot} snapshot - * @param {number} [timeout] in ms + * @param {number} timeout in ms * @classdesc * Writes the project snapshot to a zip file. */ constructor(snapshot, timeout) { assert.instance(snapshot, Snapshot) this.snapshot = snapshot - this.timeout = timeout || DEFAULT_ZIP_TIMEOUT + this.timeout = timeout } /** diff --git a/services/history-v1/test/acceptance/js/storage/project_archive.test.js b/services/history-v1/test/acceptance/js/storage/project_archive.test.js index d9112b1b67..c263ee3401 100644 --- a/services/history-v1/test/acceptance/js/storage/project_archive.test.js +++ b/services/history-v1/test/acceptance/js/storage/project_archive.test.js @@ -62,7 +62,7 @@ describe('ProjectArchive', function () { it('archives a small snapshot with binary and text data', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -83,7 +83,7 @@ describe('ProjectArchive', function () { it('archives a larger snapshot with binary and text data', function () { return makeMixedTestSnapshot(10) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -102,7 +102,7 @@ describe('ProjectArchive', function () { return blobStore .putString('') .then(() => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -134,7 +134,7 @@ describe('ProjectArchive', function () { it('rejects with the error', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -169,7 +169,7 @@ describe('ProjectArchive', function () { it('rejects with the error', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => {