mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Revert "Revert "Revert "optimize rootDoc_id validation"""
This reverts commit f015bc2bb54e98d1271bc2417647638aa80ba843. GitOrigin-RevId: ca8380891a0e71713ed33f200720a9ab92db6ef3
This commit is contained in:
parent
9c61681ae2
commit
9228fbd026
3 changed files with 64 additions and 102 deletions
|
@ -3,7 +3,6 @@ const Settings = require('settings-sharelatex')
|
|||
const request = require('request')
|
||||
const ProjectGetter = require('../Project/ProjectGetter')
|
||||
const ProjectEntityHandler = require('../Project/ProjectEntityHandler')
|
||||
const ProjectRootDocManager = require('../Project/ProjectRootDocManager')
|
||||
const logger = require('logger-sharelatex')
|
||||
const Url = require('url')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
@ -466,35 +465,15 @@ const ClsiManager = {
|
|||
return outputFiles
|
||||
},
|
||||
|
||||
_ensureRootDocumentIsValid(project, callback) {
|
||||
// if root doc is set and id is contained somewhere in directory tree then accept it
|
||||
try {
|
||||
if (
|
||||
project.rootDoc_id &&
|
||||
project.rootFolder &&
|
||||
JSON.stringify(project.rootFolder).includes(project.rootDoc_id)
|
||||
) {
|
||||
return callback()
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore errors here, which are very unlikely, and just attempt to set the root doc again
|
||||
}
|
||||
ProjectRootDocManager.setRootDocAutomatically(project._id, callback)
|
||||
},
|
||||
|
||||
_buildRequest(projectId, options, callback) {
|
||||
if (options == null) {
|
||||
options = {}
|
||||
}
|
||||
ProjectGetter.getProject(
|
||||
projectId,
|
||||
{
|
||||
compiler: 1,
|
||||
rootDoc_id: 1,
|
||||
imageName: 1,
|
||||
rootFolder: 1
|
||||
},
|
||||
{ compiler: 1, rootDoc_id: 1, imageName: 1, rootFolder: 1, rootDoc_id: 1 },
|
||||
(err, project) => {
|
||||
console.log("GGGG", project)
|
||||
if (err != null) {
|
||||
return callback(
|
||||
new OError({
|
||||
|
@ -512,15 +491,6 @@ const ClsiManager = {
|
|||
project.compiler = 'pdflatex'
|
||||
}
|
||||
|
||||
ClsiManager._ensureRootDocumentIsValid(project, err => {
|
||||
if (err != null) {
|
||||
return callback(
|
||||
new OError({
|
||||
message: 'error setting rootDoc_id',
|
||||
info: { projectId }
|
||||
}).withCause(err)
|
||||
)
|
||||
}
|
||||
if (options.incrementalCompilesEnabled || options.syncType != null) {
|
||||
// new way, either incremental or full
|
||||
const timer = new Metrics.Timer('editor.compile-getdocs-redis')
|
||||
|
@ -531,10 +501,7 @@ const ClsiManager = {
|
|||
(err, projectStateHash, docUpdaterDocs) => {
|
||||
timer.done()
|
||||
if (err != null) {
|
||||
logger.error(
|
||||
{ err, projectId },
|
||||
'error checking project state'
|
||||
)
|
||||
logger.error({ err, projectId }, 'error checking project state')
|
||||
// note: we don't bail out when there's an error getting
|
||||
// incremental files from the docupdater, we just fall back
|
||||
// to a normal compile below
|
||||
|
@ -589,7 +556,6 @@ const ClsiManager = {
|
|||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
},
|
||||
|
|
|
@ -24,9 +24,6 @@ describe('ClsiManager', function() {
|
|||
this.DocumentUpdaterHandler = {
|
||||
getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null)
|
||||
}
|
||||
this.ProjectRootDocManager = {
|
||||
setRootDocAutomatically: sinon.stub().yields()
|
||||
}
|
||||
this.logger = {
|
||||
log: sinon.stub(),
|
||||
error: sinon.stub(),
|
||||
|
@ -66,7 +63,6 @@ describe('ClsiManager', function() {
|
|||
},
|
||||
'../Project/ProjectEntityHandler': this.ProjectEntityHandler,
|
||||
'../Project/ProjectGetter': this.ProjectGetter,
|
||||
'../Project/ProjectRootDocManager': this.ProjectRootDocManager,
|
||||
'../DocumentUpdater/DocumentUpdaterHandler': this
|
||||
.DocumentUpdaterHandler,
|
||||
'./ClsiCookieManager': () => this.ClsiCookieManager,
|
||||
|
|
|
@ -76,7 +76,7 @@ describe('CompileManager', function() {
|
|||
this.CompileManager._checkIfRecentlyCompiled = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, false)
|
||||
this.ProjectRootDocManager.ensureRootDocumentIsSet = sinon
|
||||
this.ProjectRootDocManager.ensureRootDocumentIsValid = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null)
|
||||
this.CompileManager.getProjectCompileLimits = sinon
|
||||
|
@ -115,7 +115,7 @@ describe('CompileManager', function() {
|
|||
})
|
||||
|
||||
it('should ensure that the root document is set', function() {
|
||||
return this.ProjectRootDocManager.ensureRootDocumentIsSet
|
||||
return this.ProjectRootDocManager.ensureRootDocumentIsValid
|
||||
.calledWith(this.project_id)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue