From 52133a0e393b21d4595d2bcf2c5435d7a6bdca3c Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 25 Oct 2023 17:54:26 +0200 Subject: [PATCH] Merge pull request #15449 from overleaf/jpa-server-pro-4-1-5 [server-pro] prepare hotfix release 4.1.5 GitOrigin-RevId: de65501909ed5aba6eadf556d2c41ca3a8cc14e2 --- server-ce/hotfix/4.1.5/Dockerfile | 5 +++ server-ce/hotfix/4.1.5/pr_15445.patch | 44 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 server-ce/hotfix/4.1.5/Dockerfile create mode 100644 server-ce/hotfix/4.1.5/pr_15445.patch diff --git a/server-ce/hotfix/4.1.5/Dockerfile b/server-ce/hotfix/4.1.5/Dockerfile new file mode 100644 index 0000000000..ca89588075 --- /dev/null +++ b/server-ce/hotfix/4.1.5/Dockerfile @@ -0,0 +1,5 @@ +FROM sharelatex/sharelatex:4.1.4 + +# Patch: Change streaming compression in history-v1 +COPY pr_15445.patch . +RUN patch -p0 < pr_15445.patch diff --git a/server-ce/hotfix/4.1.5/pr_15445.patch b/server-ce/hotfix/4.1.5/pr_15445.patch new file mode 100644 index 0000000000..1dcd18db61 --- /dev/null +++ b/server-ce/hotfix/4.1.5/pr_15445.patch @@ -0,0 +1,44 @@ +--- services/history-v1/storage/lib/history_store.js ++++ services/history-v1/storage/lib/history_store.js +@@ -103,11 +103,11 @@ HistoryStore.prototype.storeRaw = function historyStoreStoreRaw( + assert.object(rawHistory, 'bad rawHistory') + + const key = getKey(projectId, chunkId) +- const stream = streams.gzipStringToStream(JSON.stringify(rawHistory)) + + logger.debug({ projectId, chunkId }, 'storeRaw started') + return BPromise.resolve() +- .then(() => ++ .then(() => streams.gzipStringToStream(JSON.stringify(rawHistory))) ++ .then(stream => + persistor.sendStream(BUCKET, key, stream, { + contentType: 'application/json', + contentEncoding: 'gzip', +--- services/history-v1/storage/lib/streams.js ++++ services/history-v1/storage/lib/streams.js +@@ -79,8 +79,15 @@ function gunzipStreamToBuffer(readStream) { + exports.gunzipStreamToBuffer = gunzipStreamToBuffer + + function gzipStringToStream(string) { +- const gzip = zlib.createGzip() +- return new ReadableString(string).pipe(gzip) ++ return new BPromise(function (resolve, reject) { ++ zlib.gzip(Buffer.from(string), function (error, result) { ++ if (error) { ++ reject(error) ++ } else { ++ resolve(new ReadableString(result)) ++ } ++ }) ++ }) + } + + /** +@@ -88,6 +95,6 @@ function gzipStringToStream(string) { + * + * @function + * @param {string} string +- * @return {stream.Writable} ++ * @return {Promise.} + */ + exports.gzipStringToStream = gzipStringToStream