mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Revert "File restore optimization - using snapshot timestamp and file paths (#28546)"
This reverts commit 376a53e1f927cb56544e6782b47d80345655038c. GitOrigin-RevId: 8e4ab1d4042fec8df1b62ab1c5418d873dc6f5eb
This commit is contained in:
committed by
Copybot
parent
005eba7502
commit
e9b1c63ed7
@@ -294,8 +294,6 @@ class Change {
|
||||
if (this.v2DocVersions) {
|
||||
snapshot.updateV2DocVersions(this.v2DocVersions)
|
||||
}
|
||||
|
||||
snapshot.setTimestamp(this.timestamp)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,8 +36,7 @@ class Snapshot {
|
||||
return new Snapshot(
|
||||
FileMap.fromRaw(raw.files),
|
||||
raw.projectVersion,
|
||||
V2DocVersions.fromRaw(raw.v2DocVersions),
|
||||
raw.timestamp ? new Date(raw.timestamp) : undefined
|
||||
V2DocVersions.fromRaw(raw.v2DocVersions)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,15 +45,8 @@ class Snapshot {
|
||||
const raw = {
|
||||
files: this.fileMap.toRaw(),
|
||||
}
|
||||
if (this.projectVersion) {
|
||||
raw.projectVersion = this.projectVersion
|
||||
}
|
||||
if (this.v2DocVersions) {
|
||||
raw.v2DocVersions = this.v2DocVersions.toRaw()
|
||||
}
|
||||
if (this.timestamp != null) {
|
||||
raw.timestamp = this.timestamp.toISOString()
|
||||
}
|
||||
if (this.projectVersion) raw.projectVersion = this.projectVersion
|
||||
if (this.v2DocVersions) raw.v2DocVersions = this.v2DocVersions.toRaw()
|
||||
return raw
|
||||
}
|
||||
|
||||
@@ -62,15 +54,13 @@ class Snapshot {
|
||||
* @param {FileMap} [fileMap]
|
||||
* @param {string} [projectVersion]
|
||||
* @param {V2DocVersions} [v2DocVersions]
|
||||
* @param {Date} [timestamp]
|
||||
*/
|
||||
constructor(fileMap, projectVersion, v2DocVersions, timestamp) {
|
||||
constructor(fileMap, projectVersion, v2DocVersions) {
|
||||
assert.maybe.instance(fileMap, FileMap, 'bad fileMap')
|
||||
|
||||
this.fileMap = fileMap || new FileMap({})
|
||||
this.projectVersion = projectVersion
|
||||
this.v2DocVersions = v2DocVersions
|
||||
this.timestamp = timestamp ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,17 +109,6 @@ class Snapshot {
|
||||
v2DocVersions.applyTo(this)
|
||||
}
|
||||
|
||||
getTimestamp() {
|
||||
return this.timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Date} timestamp
|
||||
*/
|
||||
setTimestamp(timestamp) {
|
||||
this.timestamp = timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
* The underlying file map.
|
||||
* @return {FileMap}
|
||||
@@ -289,7 +268,6 @@ class Snapshot {
|
||||
files: rawFiles,
|
||||
projectVersion,
|
||||
v2DocVersions: rawV2DocVersions,
|
||||
timestamp: this.getTimestamp() ?? undefined,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ export type RawSnapshot = {
|
||||
files: RawFileMap
|
||||
projectVersion?: string
|
||||
v2DocVersions?: RawV2DocVersions | null
|
||||
timestamp?: string
|
||||
}
|
||||
|
||||
export type RawHistory = {
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('chai')
|
||||
const {
|
||||
Change,
|
||||
File,
|
||||
Operation,
|
||||
AddFileOperation,
|
||||
Snapshot,
|
||||
Origin,
|
||||
RestoreFileOrigin,
|
||||
} = require('..')
|
||||
const core = require('..')
|
||||
const Change = core.Change
|
||||
const File = core.File
|
||||
const Operation = core.Operation
|
||||
|
||||
describe('Change', function () {
|
||||
describe('findBlobHashes', function () {
|
||||
@@ -42,9 +37,9 @@ describe('Change', function () {
|
||||
|
||||
describe('RestoreFileOrigin', function () {
|
||||
it('should convert to and from raw', function () {
|
||||
const origin = new RestoreFileOrigin(1, 'path', new Date())
|
||||
const origin = new core.RestoreFileOrigin(1, 'path', new Date())
|
||||
const raw = origin.toRaw()
|
||||
const newOrigin = Origin.fromRaw(raw)
|
||||
const newOrigin = core.Origin.fromRaw(raw)
|
||||
expect(newOrigin).to.eql(origin)
|
||||
})
|
||||
|
||||
@@ -61,19 +56,7 @@ describe('Change', function () {
|
||||
},
|
||||
})
|
||||
|
||||
expect(change.getOrigin()).to.be.an.instanceof(RestoreFileOrigin)
|
||||
})
|
||||
})
|
||||
|
||||
describe('applyTo', function () {
|
||||
it('sets the timestamp on the snapshot', function () {
|
||||
const snapshot = new Snapshot()
|
||||
snapshot.addFile('main.tex', File.fromString(''))
|
||||
const operation = new AddFileOperation('main.tex', File.fromString(''))
|
||||
const now = new Date()
|
||||
const change = new Change([operation], now)
|
||||
change.applyTo(snapshot)
|
||||
expect(snapshot.getTimestamp().toISOString()).to.equal(now.toISOString())
|
||||
expect(change.getOrigin()).to.be.an.instanceof(core.RestoreFileOrigin)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user