diff --git a/services/web/app/coffee/Features/Editor/EditorController.coffee b/services/web/app/coffee/Features/Editor/EditorController.coffee index d8c1dbf84b..38f788dd41 100644 --- a/services/web/app/coffee/Features/Editor/EditorController.coffee +++ b/services/web/app/coffee/Features/Editor/EditorController.coffee @@ -33,10 +33,12 @@ module.exports = EditorController = logger.log {project_id, folder_id, docName, source}, "sending new doc to project" Metrics.inc "editor.add-doc" ProjectEntityHandler.addDoc project_id, folder_id, docName, docLines, (err, doc, folder_id)=> + if err? + logger.err err:err, project_id:project_id, docName:docName, "error adding doc without lock" + return callback(err) EditorRealTimeController.emitToRoom(project_id, 'reciveNewDoc', folder_id, doc, source) callback(err, doc) - addFile: (project_id, folder_id, fileName, path, source, callback = (error, file)->)-> LockManager.getLock project_id, (err)-> if err? @@ -46,20 +48,20 @@ module.exports = EditorController = LockManager.releaseLock project_id, -> callback(error, file) - addFileWithoutLock: (project_id, folder_id, fileName, path, source, callback = (error, file)->)-> fileName = fileName.trim() logger.log {project_id, folder_id, fileName, path}, "sending new file to project" Metrics.inc "editor.add-file" ProjectEntityHandler.addFile project_id, folder_id, fileName, path, (err, fileRef, folder_id)=> + if err? + logger.err err:err, project_id:project_id, folder_id:folder_id, fileName:fileName, "error adding file without lock" + return callback(err) EditorRealTimeController.emitToRoom(project_id, 'reciveNewFile', folder_id, fileRef, source) callback(err, fileRef) replaceFile: (project_id, file_id, fsPath, source, callback = (error) ->)-> ProjectEntityHandler.replaceFile project_id, file_id, fsPath, callback - - addFolder : (project_id, folder_id, folderName, source, callback = (error, folder)->)-> LockManager.getLock project_id, (err)-> if err? @@ -74,6 +76,9 @@ module.exports = EditorController = logger.log {project_id, folder_id, folderName, source}, "sending new folder to project" Metrics.inc "editor.add-folder" ProjectEntityHandler.addFolder project_id, folder_id, folderName, (err, folder, folder_id)=> + if err? + logger.err err:err, project_id:project_id, folder_id:folder_id, folderName:folderName, "error adding folder without lock" + return callback(err) @p.notifyProjectUsersOfNewFolder project_id, folder_id, folder, (error) -> callback error, folder @@ -90,6 +95,9 @@ module.exports = EditorController = mkdirpWithoutLock: (project_id, path, callback)-> logger.log project_id:project_id, path:path, "making directories if they don't exist" ProjectEntityHandler.mkdirp project_id, path, (err, newFolders, lastFolder)=> + if err? + logger.err err:err, project_id:project_id, path:path, "error mkdirp without lock" + return callback(err) self = @ jobs = _.map newFolders, (folder, index)-> return (cb)-> @@ -109,7 +117,10 @@ module.exports = EditorController = deleteEntityWithoutLock: (project_id, entity_id, entityType, source, callback)-> logger.log {project_id, entity_id, entityType, source}, "start delete process of entity" Metrics.inc "editor.delete-entity" - ProjectEntityHandler.deleteEntity project_id, entity_id, entityType, => + ProjectEntityHandler.deleteEntity project_id, entity_id, entityType, (err)-> + if err? + logger.err err:err, project_id:project_id, entity_id:entity_id, entityType:entityType, "error deleting entity" + return callback(err) logger.log project_id:project_id, entity_id:entity_id, entityType:entityType, "telling users entity has been deleted" EditorRealTimeController.emitToRoom(project_id, 'removeEntity', entity_id, source) if callback? @@ -143,19 +154,28 @@ module.exports = EditorController = newName = sanitize.escape(newName) Metrics.inc "editor.rename-entity" logger.log entity_id:entity_id, entity_id:entity_id, entity_id:entity_id, "reciving new name for entity for project" - ProjectEntityHandler.renameEntity project_id, entity_id, entityType, newName, => + ProjectEntityHandler.renameEntity project_id, entity_id, entityType, newName, -> + if err? + logger.err err:err, project_id:project_id, entity_id:entity_id, entityType:entityType, newName:newName, "error renaming entity" + return callback(err) if newName.length > 0 EditorRealTimeController.emitToRoom project_id, 'reciveEntityRename', entity_id, newName callback?() -# + moveEntity: (project_id, entity_id, folder_id, entityType, callback)-> Metrics.inc "editor.move-entity" ProjectEntityHandler.moveEntity project_id, entity_id, folder_id, entityType, => + if err? + logger.err err:err, project_id:project_id, entity_id:entity_id, folder_id:folder_id, "error moving entity" + return callback(err) EditorRealTimeController.emitToRoom project_id, 'reciveEntityMove', entity_id, folder_id callback?() renameProject: (project_id, newName, callback = (err) ->) -> - ProjectDetailsHandler.renameProject project_id, newName, => + ProjectDetailsHandler.renameProject project_id, newName, -> + if err? + logger.err err:err, project_id:project_id, newName:newName, "error renaming project" + return callback(err) EditorRealTimeController.emitToRoom project_id, 'projectNameUpdated', newName callback()