mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #19298 from overleaf/em-fix-restore-empty-file
Fix file restore when the file is empty GitOrigin-RevId: be08305c9a41265acfb12046aeb2d003cda92b54
This commit is contained in:
parent
fbdf245517
commit
58ffefc8bb
2 changed files with 20 additions and 1 deletions
|
@ -78,7 +78,7 @@ async function getRangesSnapshot(projectId, version, pathname) {
|
|||
const historyId = await WebApiManager.promises.getHistoryId(projectId)
|
||||
await file.load('eager', HistoryStoreManager.getBlobStore(historyId))
|
||||
const content = file.getContent()
|
||||
if (!content) {
|
||||
if (content == null) {
|
||||
throw new Error('Unable to read file contents')
|
||||
}
|
||||
const trackedChanges = file.getTrackedChanges().asSorted()
|
||||
|
|
|
@ -978,5 +978,24 @@ Four five six\
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an empty file', function () {
|
||||
beforeEach(async function () {
|
||||
this.getString.resolves('')
|
||||
this.getObject.resolves({})
|
||||
this.data = await this.SnapshotManager.promises.getRangesSnapshot(
|
||||
this.projectId,
|
||||
1,
|
||||
'main.tex'
|
||||
)
|
||||
})
|
||||
|
||||
it('should return empty comments and changes', function () {
|
||||
expect(this.data).to.deep.equal({
|
||||
changes: [],
|
||||
comments: [],
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue