don't stop if add entity doens't make it to tpdsworker

This commit is contained in:
Henry Oswald 2016-03-02 17:34:21 +00:00
parent 39c7010d72
commit 4af0341e84
2 changed files with 11 additions and 4 deletions

View file

@ -7,6 +7,8 @@ DocstoreManager = require "../Docstore/DocstoreManager"
ProjectGetter = require("./ProjectGetter")
_ = require('underscore')
async = require('async')
logger = require("logger-sharelatex")
module.exports =
duplicate: (owner, originalProjectId, newProjectName, callback)->
@ -29,13 +31,15 @@ module.exports =
setRootDoc = _.once (doc_id)->
projectEntityHandler.setRootDoc newProject, doc_id
copyDocs = (originalFolder, newParentFolder, callback)->
jobs = originalFolder.docs.map (doc)->
return (callback)->
content = docContents[doc._id.toString()]
return callback(new Error("doc_id not found: #{doc._id}")) if !content?
projectEntityHandler.addDoc newProject, newParentFolder._id, doc.name, content.lines, (err, newDoc)->
if err?
logger.err err:err, originalProjectId:originalProjectId, newProjectName:newProjectName, "error adding doc"
return callback(err)
if originalRootDoc? and newDoc.name == originalRootDoc.name
setRootDoc newDoc._id
callback()
@ -59,6 +63,8 @@ module.exports =
async.series jobs, callback
copyFolder originalProject.rootFolder[0], newProject.rootFolder[0], ->
copyFolder originalProject.rootFolder[0], newProject.rootFolder[0], (err)->
if err?
logger.err err:err, originalProjectId:originalProjectId, newProjectName:newProjectName, "error cloning project"
callback(err, newProject)

View file

@ -124,12 +124,13 @@ module.exports = ProjectEntityHandler =
return callback(err) if err?
tpdsUpdateSender.addDoc {
project_id: project?._id,
doc_id: doc?._id
doc_id: doc?._id
path: result?.path?.fileSystem,
project_name: project.name,
rev: 0
}, (err) ->
return callback(err) if err?
if err?
logger.err err:err, "error adding doc to tpdsworker, contining anyway"
callback(null, doc, folder_id)
restoreDoc: (project_id, doc_id, name, callback = (error, doc, folder_id) ->) ->