Revert "Revert "Revert "format fix"""

This reverts commit abb3f94c50b94cd87012d9e55c40afd9cbfe97e0.

GitOrigin-RevId: 090e01b96222024341e3c988ec3ba4c9fa1eef11
This commit is contained in:
Ersun Warncke 2020-02-11 09:19:47 -04:00 committed by Copybot
parent 02140124bd
commit b4cdfc43cf
3 changed files with 44 additions and 66 deletions

View file

@ -44,10 +44,7 @@ module.exports = CompileController = {
if (req.body.rootDoc_id) { if (req.body.rootDoc_id) {
options.rootDoc_id = req.body.rootDoc_id options.rootDoc_id = req.body.rootDoc_id
} else if ( } else if (req.body.settingsOverride && req.body.settingsOverride.rootDoc_id) {
req.body.settingsOverride &&
req.body.settingsOverride.rootDoc_id
) {
// Can be removed after deploy // Can be removed after deploy
options.rootDoc_id = req.body.settingsOverride.rootDoc_id options.rootDoc_id = req.body.settingsOverride.rootDoc_id
} }
@ -57,18 +54,16 @@ module.exports = CompileController = {
if (req.body.draft) { if (req.body.draft) {
options.draft = req.body.draft options.draft = req.body.draft
} }
if (['validate', 'error', 'silent'].includes(req.body.check)) { if (
['validate', 'error', 'silent'].includes(req.body.check)
) {
options.check = req.body.check options.check = req.body.check
} }
if (req.body.incrementalCompilesEnabled) { if (req.body.incrementalCompilesEnabled) {
options.incrementalCompilesEnabled = true options.incrementalCompilesEnabled = true
} }
CompileManager.compile( CompileManager.compile(project_id, user_id, options, (
project_id,
user_id,
options,
(
error, error,
status, status,
outputFiles, outputFiles,
@ -87,8 +82,7 @@ module.exports = CompileController = {
validationProblems, validationProblems,
pdfDownloadDomain: Settings.pdfDownloadDomain pdfDownloadDomain: Settings.pdfDownloadDomain
}) })
} })
)
}, },
stopCompile(req, res, next) { stopCompile(req, res, next) {

View file

@ -316,10 +316,7 @@ async function deleteEntity(projectId, entityId, entityType, callback) {
projectId, projectId,
{ name: true, rootFolder: true, overleaf: true, rootDoc_id: true } { name: true, rootFolder: true, overleaf: true, rootDoc_id: true }
) )
const deleteRootDoc = const deleteRootDoc = project.rootDoc_id && entityId && project.rootDoc_id.toString() === entityId.toString()
project.rootDoc_id &&
entityId &&
project.rootDoc_id.toString() === entityId.toString()
const { element: entity, path } = await ProjectLocator.promises.findElement({ const { element: entity, path } = await ProjectLocator.promises.findElement({
project, project,
element_id: entityId, element_id: entityId,
@ -419,13 +416,7 @@ async function _insertDeletedFileReference(projectId, fileRef) {
).exec() ).exec()
} }
async function _removeElementFromMongoArray( async function _removeElementFromMongoArray(model, modelId, path, elementId, deleteRootDoc=false) {
model,
modelId,
path,
elementId,
deleteRootDoc = false
) {
const nonArrayPath = path.slice(0, path.lastIndexOf('.')) const nonArrayPath = path.slice(0, path.lastIndexOf('.'))
const options = { new: true } const options = { new: true }
const query = { _id: modelId } const query = { _id: modelId }

View file

@ -1113,25 +1113,22 @@ describe('ProjectStructureChanges', function() {
} }
this.project0 = project this.project0 = project
done() done()
} })
)
}) })
}) })
}) })
}) })
describe('when rootDoc_id matches doc being deleted', function() { describe('when rootDoc_id matches doc being deleted', () => {
beforeEach(function(done) { beforeEach(function(done) {
Project.update( Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleDocId}}, done)
{ _id: this.exampleProjectId },
{ $set: { rootDoc_id: this.exampleDocId } },
done
)
}) })
it('should clear rootDoc_id', function(done) { it('should clear rootDoc_id', function(done) {
deleteItem(this, 'doc', this.exampleDocId, () => { deleteItem(this, 'doc', this.exampleDocId, () => {
ProjectGetter.getProject(this.exampleProjectId, (error, project) => { ProjectGetter.getProject(
this.exampleProjectId,
(error, project) => {
if (error) { if (error) {
throw error throw error
} }
@ -1142,25 +1139,21 @@ describe('ProjectStructureChanges', function() {
}) })
}) })
describe('when rootDoc_id does not match doc being deleted', function() { describe('when rootDoc_id does not match doc being deleted', () => {
beforeEach(function(done) { beforeEach(function(done) {
this.exampleRootDocId = new ObjectId() this.exampleRootDocId = new ObjectId()
Project.update( Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleRootDocId}}, done)
{ _id: this.exampleProjectId },
{ $set: { rootDoc_id: this.exampleRootDocId } },
done
)
}) })
it('should not clear rootDoc_id', function(done) { it('should not clear rootDoc_id', function(done) {
deleteItem(this, 'doc', this.exampleDocId, () => { deleteItem(this, 'doc', this.exampleDocId, () => {
ProjectGetter.getProject(this.exampleProjectId, (error, project) => { ProjectGetter.getProject(
this.exampleProjectId,
(error, project) => {
if (error) { if (error) {
throw error throw error
} }
expect(project.rootDoc_id.toString()).to.equal( expect(project.rootDoc_id.toString()).to.equal(this.exampleRootDocId.toString())
this.exampleRootDocId.toString()
)
done() done()
}) })
}) })