mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Revert "add ensureRootDocumentIsValidForProject method"
This reverts commit 5b9191bce2fe1de85c573ed533521e53f08d146b. GitOrigin-RevId: 80bb46f92f200f48fc39138afb27df729959888c
This commit is contained in:
parent
e018663af5
commit
93c8779ff7
2 changed files with 47 additions and 49 deletions
|
@ -204,31 +204,21 @@ module.exports = ProjectRootDocManager = {
|
|||
if (callback == null) {
|
||||
callback = function(error) {}
|
||||
}
|
||||
return ProjectGetter.getProject(
|
||||
project_id,
|
||||
{ rootDoc_id: 1, rootFolder: 1 },
|
||||
function(error, project) {
|
||||
return ProjectGetter.getProject(project_id, { rootDoc_id: 1 }, function(
|
||||
error,
|
||||
project
|
||||
) {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
if (project == null) {
|
||||
return callback(new Error('project not found'))
|
||||
}
|
||||
ProjectRootDocManager.ensureRootDocumentIsValidForProject(
|
||||
project,
|
||||
callback
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
ensureRootDocumentIsValidForProject(project, callback) {
|
||||
const project_id = project._id
|
||||
if (project.rootDoc_id != null) {
|
||||
return ProjectEntityHandler.getAllDocPathsFromProject(project, function(
|
||||
error,
|
||||
docPaths
|
||||
) {
|
||||
return ProjectEntityHandler.getAllDocPathsFromProjectById(
|
||||
project_id,
|
||||
function(error, docPaths) {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
|
@ -243,13 +233,21 @@ module.exports = ProjectRootDocManager = {
|
|||
return callback()
|
||||
} else {
|
||||
return ProjectEntityUpdateHandler.unsetRootDoc(project_id, () =>
|
||||
ProjectRootDocManager.setRootDocAutomatically(project_id, callback)
|
||||
ProjectRootDocManager.setRootDocAutomatically(
|
||||
project_id,
|
||||
callback
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return ProjectRootDocManager.setRootDocAutomatically(
|
||||
project_id,
|
||||
callback
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return ProjectRootDocManager.setRootDocAutomatically(project_id, callback)
|
||||
}
|
||||
},
|
||||
|
||||
_sortFileList(listToSort, rootDirectory, callback) {
|
||||
|
|
|
@ -575,13 +575,13 @@ describe('ProjectRootDocManager', function() {
|
|||
|
||||
describe('ensureRootDocumentIsValid', function() {
|
||||
beforeEach(function() {
|
||||
this.project = { _id: this.project_id }
|
||||
this.project = {}
|
||||
this.ProjectGetter.getProject = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, this.project)
|
||||
this.ProjectEntityUpdateHandler.setRootDoc = sinon.stub().yields()
|
||||
this.ProjectEntityUpdateHandler.unsetRootDoc = sinon.stub().yields()
|
||||
this.ProjectEntityHandler.getAllDocPathsFromProject = sinon
|
||||
this.ProjectEntityHandler.getAllDocPathsFromProjectById = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, this.docPaths)
|
||||
return (this.ProjectRootDocManager.setRootDocAutomatically = sinon
|
||||
|
@ -599,9 +599,9 @@ describe('ProjectRootDocManager', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should find the project fetching only the rootDoc_id and rootFolder fields', function() {
|
||||
it('should find the project fetching only the rootDoc_id field', function() {
|
||||
return this.ProjectGetter.getProject
|
||||
.calledWith(this.project_id, { rootDoc_id: 1, rootFolder: 1 })
|
||||
.calledWith(this.project_id, { rootDoc_id: 1 })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
|
@ -625,9 +625,9 @@ describe('ProjectRootDocManager', function() {
|
|||
)
|
||||
})
|
||||
|
||||
it('should find the project fetching only the rootDoc_id and rootFolder fields', function() {
|
||||
it('should find the project fetching only the rootDoc_id field', function() {
|
||||
return this.ProjectGetter.getProject
|
||||
.calledWith(this.project_id, { rootDoc_id: 1, rootFolder: 1 })
|
||||
.calledWith(this.project_id, { rootDoc_id: 1 })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue