diff --git a/services/history-v1/storage/lib/persist_changes.js b/services/history-v1/storage/lib/persist_changes.js index 8a848aa214..2000bc6cbd 100644 --- a/services/history-v1/storage/lib/persist_changes.js +++ b/services/history-v1/storage/lib/persist_changes.js @@ -11,6 +11,7 @@ const History = core.History const assert = require('./assert') const chunkStore = require('./chunk_store') +const chunkBuffer = require('./chunk_buffer') const { BlobStore } = require('./blob_store') const { InvalidChangeError } = require('./errors') const { getContentHash } = require('./content_hash') @@ -180,7 +181,7 @@ async function persistChanges(projectId, allChanges, limits, clientEndVersion) { } async function extendLastChunkIfPossible() { - const latestChunk = await chunkStore.loadLatest(projectId) + const latestChunk = await chunkBuffer.loadLatest(projectId) currentChunk = latestChunk originalEndVersion = latestChunk.getEndVersion() diff --git a/services/history-v1/test/acceptance/js/api/project_updates.test.js b/services/history-v1/test/acceptance/js/api/project_updates.test.js index d67000245a..eb7b1703a7 100644 --- a/services/history-v1/test/acceptance/js/api/project_updates.test.js +++ b/services/history-v1/test/acceptance/js/api/project_updates.test.js @@ -22,6 +22,7 @@ const TextOperation = core.TextOperation const V2DocVersions = core.V2DocVersions const knex = require('../../../../storage').knex +const redis = require('../../../../storage/lib/chunk_store/redis') describe('history import', function () { beforeEach(cleanup.everything) @@ -580,7 +581,7 @@ describe('history import', function () { .catch(expectResponse.unprocessableEntity) .then(getLatestContent) .then(response => { - // Check that no chaes were made + // Check that no changes were made const snapshot = Snapshot.fromRaw(response.obj) expect(snapshot.countFiles()).to.equal(1) expect(snapshot.getFile(mainFilePathname).getHash()).to.equal( @@ -594,6 +595,10 @@ describe('history import', function () { testFiles.NULL_CHARACTERS_TXT_BYTE_LENGTH ) }) + .then(() => { + // Now clear the cache because we have changed the string length in the database + return redis.clearCache(testProjectId) + }) .then(importChanges) .then(getLatestContent) .then(response => {