mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
check for duplicates in addFolder
This commit is contained in:
parent
b537747ccd
commit
c6cca79737
1 changed files with 14 additions and 11 deletions
|
@ -341,7 +341,7 @@ module.exports = ProjectEntityHandler =
|
||||||
callback(null, folders, lastFolder)
|
callback(null, folders, lastFolder)
|
||||||
|
|
||||||
addFolder: (project_id, parentFolder_id, folderName, callback) ->
|
addFolder: (project_id, parentFolder_id, folderName, callback) ->
|
||||||
ProjectGetter.getProjectWithOnlyFolders project_id, (err, project)=>
|
ProjectGetter.getProject project_id, {}, (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)
|
||||||
|
@ -459,11 +459,14 @@ module.exports = ProjectEntityHandler =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
projectLocator.findElement {project:project, element_id:entity_id, type:entityType}, (error, entity, entPath)=>
|
projectLocator.findElement {project:project, element_id:entity_id, type:entityType}, (error, entity, entPath)=>
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
|
ProjectEntityHandler.checkElementName entity, newName, (err) =>
|
||||||
|
return callback(err) if err?
|
||||||
endPath = path.join(path.dirname(entPath.fileSystem), newName)
|
endPath = path.join(path.dirname(entPath.fileSystem), newName)
|
||||||
conditions = {_id:project_id}
|
conditions = {_id:project_id}
|
||||||
update = "$set":{}
|
update = "$set":{}
|
||||||
namePath = entPath.mongo+".name"
|
namePath = entPath.mongo+".name"
|
||||||
update["$set"][namePath] = newName
|
update["$set"][namePath] = newName
|
||||||
|
# FIXME check if this would create a duplicate file!
|
||||||
tpdsUpdateSender.moveEntity({project_id:project_id, startPath:entPath.fileSystem, endPath:endPath, project_name:project.name, rev:entity.rev})
|
tpdsUpdateSender.moveEntity({project_id:project_id, startPath:entPath.fileSystem, endPath:endPath, project_name:project.name, rev:entity.rev})
|
||||||
Project.findOneAndUpdate conditions, update, { "new": true}, (error, newProject) ->
|
Project.findOneAndUpdate conditions, update, { "new": true}, (error, newProject) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
|
|
Loading…
Reference in a new issue