Merge pull request #25224 from overleaf/em-disable-chunk-buffer

Bypass chunk buffer when loading the latest chunk

GitOrigin-RevId: 98a15b496b0d52802f9b61cefb60a7b8df653fb2
This commit is contained in:
Brian Gough
2025-05-01 09:26:11 +01:00
committed by Copybot
parent ae00328db3
commit 668011c38f
2 changed files with 5 additions and 7 deletions
@@ -18,7 +18,6 @@ const {
HashCheckBlobStore,
ProjectArchive,
zipStore,
chunkBuffer,
} = require('../../storage')
const render = require('./render')
@@ -45,7 +44,7 @@ async function initializeProject(req, res, next) {
async function getLatestContent(req, res, next) {
const projectId = req.swagger.params.project_id.value
const blobStore = new BlobStore(projectId)
const chunk = await chunkBuffer.loadLatest(projectId)
const chunk = await chunkStore.loadLatest(projectId)
const snapshot = chunk.getSnapshot()
snapshot.applyAll(chunk.getChanges())
await snapshot.loadFiles('eager', blobStore)
@@ -64,7 +63,7 @@ async function getContentAtVersion(req, res, next) {
async function getLatestHashedContent(req, res, next) {
const projectId = req.swagger.params.project_id.value
const blobStore = new HashCheckBlobStore(new BlobStore(projectId))
const chunk = await chunkBuffer.loadLatest(projectId)
const chunk = await chunkStore.loadLatest(projectId)
const snapshot = chunk.getSnapshot()
snapshot.applyAll(chunk.getChanges())
await snapshot.loadFiles('eager', blobStore)
@@ -75,7 +74,7 @@ async function getLatestHashedContent(req, res, next) {
async function getLatestHistory(req, res, next) {
const projectId = req.swagger.params.project_id.value
try {
const chunk = await chunkBuffer.loadLatest(projectId)
const chunk = await chunkStore.loadLatest(projectId)
const chunkResponse = new ChunkResponse(chunk)
res.json(chunkResponse.toRaw())
} catch (err) {
@@ -154,7 +153,7 @@ async function getChanges(req, res, next) {
}
const changes = []
let chunk = await chunkBuffer.loadLatest(projectId)
let chunk = await chunkStore.loadLatest(projectId)
if (since > chunk.getEndVersion()) {
return res.status(400).json({
@@ -11,7 +11,6 @@ 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')
@@ -181,7 +180,7 @@ async function persistChanges(projectId, allChanges, limits, clientEndVersion) {
}
async function extendLastChunkIfPossible() {
const latestChunk = await chunkBuffer.loadLatest(projectId)
const latestChunk = await chunkStore.loadLatest(projectId)
currentChunk = latestChunk
originalEndVersion = latestChunk.getEndVersion()