mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 06:39:01 +02:00
Merge pull request #26219 from overleaf/bg-history-redis-fix-loadAtTimestamp
correct startVersion calculation in loadAtTimestamp GitOrigin-RevId: ad46aae47c0769943e787199d68e895cf139bb56
This commit is contained in:
@@ -190,6 +190,7 @@ async function loadAtTimestamp(projectId, timestamp, opts = {}) {
|
||||
const chunkRecord = await backend.getChunkForTimestamp(projectId, timestamp)
|
||||
const rawHistory = await historyStore.loadRaw(projectId, chunkRecord.id)
|
||||
const history = History.fromRaw(rawHistory)
|
||||
const startVersion = chunkRecord.endVersion - history.countChanges()
|
||||
|
||||
if (!opts.persistedOnly) {
|
||||
const nonPersistedChanges = await getChunkExtension(
|
||||
@@ -200,7 +201,7 @@ async function loadAtTimestamp(projectId, timestamp, opts = {}) {
|
||||
}
|
||||
|
||||
await lazyLoadHistoryFiles(history, batchBlobStore)
|
||||
return new Chunk(history, chunkRecord.endVersion - history.countChanges())
|
||||
return new Chunk(history, startVersion)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -509,6 +509,12 @@ describe('chunkStore', function () {
|
||||
.getChanges()
|
||||
.concat(queuedChanges)
|
||||
expect(chunk.getChanges()).to.deep.equal(expectedChanges)
|
||||
expect(chunk.getStartVersion()).to.equal(
|
||||
thirdChunk.getStartVersion()
|
||||
)
|
||||
expect(chunk.getEndVersion()).to.equal(
|
||||
thirdChunk.getEndVersion() + queuedChanges.length
|
||||
)
|
||||
})
|
||||
|
||||
it("doesn't include the queued changes when getting another chunk by timestamp", async function () {
|
||||
|
||||
Reference in New Issue
Block a user