mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
use ProjectRootDocManager in ClsiManager
GitOrigin-RevId: 4687a9be32c34e9ea92b2b53cb72d71242e7dfa1
This commit is contained in:
parent
77ad61d86a
commit
f53f70cdc7
2 changed files with 86 additions and 97 deletions
|
@ -466,26 +466,6 @@ const ClsiManager = {
|
||||||
return outputFiles
|
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) {
|
|
||||||
// continue on errors, which are very unlikely, and just attempt to set the root doc again
|
|
||||||
logger.error(
|
|
||||||
{ err, project_id: project._id, rootDoc_id: project.rootDoc_id },
|
|
||||||
'error validating rootDoc_id'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
ProjectRootDocManager.setRootDocAutomatically(project._id, callback)
|
|
||||||
},
|
|
||||||
|
|
||||||
_buildRequest(projectId, options, callback) {
|
_buildRequest(projectId, options, callback) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {}
|
options = {}
|
||||||
|
@ -516,7 +496,9 @@ const ClsiManager = {
|
||||||
project.compiler = 'pdflatex'
|
project.compiler = 'pdflatex'
|
||||||
}
|
}
|
||||||
|
|
||||||
ClsiManager._ensureRootDocumentIsValid(project, err => {
|
ProjectRootDocManager.ensureRootDocumentIsValidForProject(
|
||||||
|
project,
|
||||||
|
err => {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(
|
return callback(
|
||||||
new OError({
|
new OError({
|
||||||
|
@ -525,7 +507,10 @@ const ClsiManager = {
|
||||||
}).withCause(err)
|
}).withCause(err)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (options.incrementalCompilesEnabled || options.syncType != null) {
|
if (
|
||||||
|
options.incrementalCompilesEnabled ||
|
||||||
|
options.syncType != null
|
||||||
|
) {
|
||||||
// new way, either incremental or full
|
// new way, either incremental or full
|
||||||
const timer = new Metrics.Timer('editor.compile-getdocs-redis')
|
const timer = new Metrics.Timer('editor.compile-getdocs-redis')
|
||||||
ClsiManager.getContentFromDocUpdaterIfMatch(
|
ClsiManager.getContentFromDocUpdaterIfMatch(
|
||||||
|
@ -573,7 +558,9 @@ const ClsiManager = {
|
||||||
} else {
|
} else {
|
||||||
// old way, always from mongo
|
// old way, always from mongo
|
||||||
const timer = new Metrics.Timer('editor.compile-getdocs-mongo')
|
const timer = new Metrics.Timer('editor.compile-getdocs-mongo')
|
||||||
ClsiManager._getContentFromMongo(projectId, (err, docs, files) => {
|
ClsiManager._getContentFromMongo(
|
||||||
|
projectId,
|
||||||
|
(err, docs, files) => {
|
||||||
timer.done()
|
timer.done()
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return callback(
|
return callback(
|
||||||
|
@ -591,9 +578,11 @@ const ClsiManager = {
|
||||||
files,
|
files,
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe('ClsiManager', function() {
|
||||||
getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null)
|
getProjectDocsIfMatch: sinon.stub().callsArgWith(2, null, null)
|
||||||
}
|
}
|
||||||
this.ProjectRootDocManager = {
|
this.ProjectRootDocManager = {
|
||||||
setRootDocAutomatically: sinon.stub().yields()
|
ensureRootDocumentIsValidForProject: sinon.stub().yields()
|
||||||
}
|
}
|
||||||
this.logger = {
|
this.logger = {
|
||||||
log: sinon.stub(),
|
log: sinon.stub(),
|
||||||
|
|
Loading…
Reference in a new issue