add overleaf to projections for project structure updates

This commit is contained in:
Hayden Faulds 2018-04-13 13:33:35 +01:00
parent 9ef40902ca
commit 7755a7cc1f
2 changed files with 18 additions and 18 deletions

View file

@ -31,7 +31,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
LOCK_NAMESPACE: LOCK_NAMESPACE LOCK_NAMESPACE: LOCK_NAMESPACE
addDoc: wrapWithLock (project_id, folder_id, doc, callback = (err, result) ->) -> addDoc: wrapWithLock (project_id, folder_id, doc, callback = (err, result) ->) ->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true}, (err, project) -> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (err, project) ->
if err? if err?
logger.err project_id:project_id, err:err, "error getting project for add doc" logger.err project_id:project_id, err:err, "error getting project for add doc"
return callback(err) return callback(err)
@ -40,7 +40,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
self._putElement project, folder_id, doc, "doc", callback self._putElement project, folder_id, doc, "doc", callback
addFile: wrapWithLock (project_id, folder_id, fileRef, callback = (error, result, project) ->)-> addFile: wrapWithLock (project_id, folder_id, fileRef, callback = (error, result, project) ->)->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true}, (err, project) -> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (err, project) ->
if err? if err?
logger.err project_id:project_id, err:err, "error getting project for add file" logger.err project_id:project_id, err:err, "error getting project for add file"
return callback(err) return callback(err)
@ -49,7 +49,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
self._putElement project, folder_id, fileRef, "file", callback self._putElement project, folder_id, fileRef, "file", callback
replaceFileWithNew: wrapWithLock (project_id, file_id, newFileRef, callback) -> replaceFileWithNew: wrapWithLock (project_id, file_id, newFileRef, callback) ->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder: true, name:true}, (err, project) -> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (err, project) ->
return callback(err) if err? return callback(err) if err?
ProjectLocator.findElement {project:project, element_id: file_id, type: 'file'}, (err, fileRef, path)=> ProjectLocator.findElement {project:project, element_id: file_id, type: 'file'}, (err, fileRef, path)=>
return callback(err) if err? return callback(err) if err?
@ -110,7 +110,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
callback null, folders, lastFolder callback null, folders, lastFolder
moveEntity: wrapWithLock (project_id, entity_id, destFolderId, entityType, callback = (error) ->) -> moveEntity: wrapWithLock (project_id, entity_id, destFolderId, entityType, callback = (error) ->) ->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true}, (err, project) -> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (err, project) ->
return callback(err) if err? return callback(err) if err?
ProjectLocator.findElement {project, element_id: entity_id, type: entityType}, (err, entity, entityPath)-> ProjectLocator.findElement {project, element_id: entity_id, type: entityType}, (err, entity, entityPath)->
return callback(err) if err? return callback(err) if err?
@ -127,10 +127,10 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
startPath = entityPath.fileSystem startPath = entityPath.fileSystem
endPath = result.path.fileSystem endPath = result.path.fileSystem
changes = {oldDocs, newDocs, oldFiles, newFiles} changes = {oldDocs, newDocs, oldFiles, newFiles}
callback null, project.name, startPath, endPath, entity.rev, changes, callback callback null, project, startPath, endPath, entity.rev, changes, callback
deleteEntity: wrapWithLock (project_id, entity_id, entityType, callback) -> deleteEntity: wrapWithLock (project_id, entity_id, entityType, callback) ->
ProjectGetter.getProjectWithoutLock project_id, {name:true, rootFolder:true}, (error, project) -> ProjectGetter.getProjectWithoutLock project_id, {name:true, rootFolder:true, overleaf:true}, (error, project) ->
return callback(error) if error? return callback(error) if error?
ProjectLocator.findElement {project: project, element_id: entity_id, type: entityType}, (error, entity, path) -> ProjectLocator.findElement {project: project, element_id: entity_id, type: entityType}, (error, entity, path) ->
return callback(error) if error? return callback(error) if error?
@ -139,7 +139,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
callback null, entity, path, project callback null, entity, path, project
renameEntity: wrapWithLock (project_id, entity_id, entityType, newName, callback) -> renameEntity: wrapWithLock (project_id, entity_id, entityType, newName, callback) ->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true}, (error, project)=> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (error, project)=>
return callback(error) if error? return callback(error) if error?
ProjectEntityHandler.getAllEntitiesFromProject project, (error, oldDocs, oldFiles) => ProjectEntityHandler.getAllEntitiesFromProject project, (error, oldDocs, oldFiles) =>
return callback(error) if error? return callback(error) if error?
@ -161,10 +161,10 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
return callback(error) if error? return callback(error) if error?
startPath = entPath.fileSystem startPath = entPath.fileSystem
changes = {oldDocs, newDocs, oldFiles, newFiles} changes = {oldDocs, newDocs, oldFiles, newFiles}
callback null, project.name, startPath, endPath, entity.rev, changes, callback callback null, project, startPath, endPath, entity.rev, changes, callback
addFolder: wrapWithLock (project_id, parentFolder_id, folderName, callback) -> addFolder: wrapWithLock (project_id, parentFolder_id, folderName, callback) ->
ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true}, (err, project) -> ProjectGetter.getProjectWithoutLock project_id, {rootFolder:true, name:true, overleaf:true}, (err, project) ->
if err? if err?
logger.err project_id:project_id, err:err, "error getting project for add folder" logger.err project_id:project_id, err:err, "error getting project for add folder"
return callback(err) return callback(err)

View file

@ -57,7 +57,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'gets the project', -> it 'gets the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name: true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'checks the folder exists', -> it 'checks the folder exists', ->
@ -80,7 +80,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'gets the project', -> it 'gets the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name: true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'checks the folder exists', -> it 'checks the folder exists', ->
@ -106,7 +106,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'gets the project', -> it 'gets the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name: true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'finds the existing element', -> it 'finds the existing element', ->
@ -241,7 +241,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'should get the project', -> it 'should get the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name:true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'should find the doc to move', -> it 'should find the doc to move', ->
@ -280,7 +280,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it "should get the project", -> it "should get the project", ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {name:true, rootFolder:true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it "should find the element", -> it "should find the element", ->
@ -325,7 +325,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'should get the project', -> it 'should get the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name:true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'should find the doc', -> it 'should find the doc', ->
@ -363,7 +363,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
it 'gets the project', -> it 'gets the project', ->
@ProjectGetter.getProjectWithoutLock @ProjectGetter.getProjectWithoutLock
.calledWith(project_id, {rootFolder:true, name: true}) .calledWith(project_id, {rootFolder:true, name:true, overleaf:true})
.should.equal true .should.equal true
it 'checks the parent folder exists', -> it 'checks the parent folder exists', ->