Kaynağa Gözat

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

Bypass chunk buffer when loading the latest chunk

GitOrigin-RevId: 98a15b496b0d52802f9b61cefb60a7b8df653fb2
Brian Gough 1 yıl önce
ebeveyn
işleme
4464320757

+ 4 - 5
services/history-v1/api/controllers/projects.js

@@ -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({

+ 1 - 2
services/history-v1/storage/lib/persist_changes.js

@@ -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()