mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-11 02:04:53 +00:00
Don't error if the rootDoc_id no longer exists in the project when copying
This commit is contained in:
parent
a24f635531
commit
887631e661
3 changed files with 15 additions and 2 deletions
|
@ -75,7 +75,7 @@ module.exports = ProjectDuplicator =
|
|||
return callback(err)
|
||||
{originalProject, newProject, originalRootDoc, docContentsArray} = results
|
||||
|
||||
originalRootDoc = originalRootDoc[0]
|
||||
originalRootDoc = originalRootDoc?[0]
|
||||
|
||||
docContents = {}
|
||||
for docContent in docContentsArray
|
||||
|
|
|
@ -61,7 +61,13 @@ module.exports = ProjectLocator =
|
|||
findRootDoc : (opts, callback)->
|
||||
getRootDoc = (project)=>
|
||||
if project.rootDoc_id?
|
||||
@findElement {project:project, element_id:project.rootDoc_id, type:"docs"}, callback
|
||||
@findElement {project:project, element_id:project.rootDoc_id, type:"docs"}, (error, args...) ->
|
||||
if error?
|
||||
if error instanceof Errors.NotFoundError
|
||||
return callback null, null
|
||||
else
|
||||
return callback error
|
||||
return callback null, args...
|
||||
else
|
||||
callback null, null
|
||||
{project, project_id} = opts
|
||||
|
|
|
@ -169,6 +169,13 @@ describe 'ProjectLocator', ->
|
|||
assert !err?
|
||||
expect(doc).to.equal null
|
||||
done()
|
||||
|
||||
it 'should return null when the rootDoc_id no longer exists', (done) ->
|
||||
project.rootDoc_id = "doesntexist"
|
||||
@locator.findRootDoc project, (err, doc)->
|
||||
assert !err?
|
||||
expect(doc).to.equal null
|
||||
done()
|
||||
|
||||
describe 'findElementByPath', ->
|
||||
|
||||
|
|
Loading…
Reference in a new issue