mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
check for duplicates on move
This commit is contained in:
parent
3881eb1d78
commit
4f5a5cb677
1 changed files with 11 additions and 10 deletions
|
@ -395,7 +395,7 @@ module.exports = ProjectEntityHandler =
|
||||||
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?
|
||||||
self._checkValidMove project, entityType, entityPath, destFolderId, (error) ->
|
self._checkValidMove project, entityType, entity, entityPath, destFolderId, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
self.getAllEntitiesFromProject project, (error, oldDocs, oldFiles) =>
|
self.getAllEntitiesFromProject project, (error, oldDocs, oldFiles) =>
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
|
@ -414,19 +414,20 @@ module.exports = ProjectEntityHandler =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
DocumentUpdaterHandler.updateProjectStructure project_id, userId, {oldDocs, newDocs, oldFiles, newFiles}, callback
|
DocumentUpdaterHandler.updateProjectStructure project_id, userId, {oldDocs, newDocs, oldFiles, newFiles}, callback
|
||||||
|
|
||||||
_checkValidMove: (project, entityType, entityPath, destFolderId, callback = (error) ->) ->
|
_checkValidMove: (project, entityType, entity, entityPath, destFolderId, callback = (error) ->) ->
|
||||||
return callback() if !entityType.match(/folder/)
|
|
||||||
|
|
||||||
projectLocator.findElement { project, element_id: destFolderId, type:"folder"}, (err, destEntity, destFolderPath) ->
|
projectLocator.findElement { project, element_id: destFolderId, type:"folder"}, (err, destEntity, destFolderPath) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
logger.log destFolderPath: destFolderPath.fileSystem, folderPath: entityPath.fileSystem, "checking folder is not moving into child folder"
|
# check if there is already a doc/file/folder with the same name
|
||||||
isNestedFolder = destFolderPath.fileSystem.slice(0, entityPath.fileSystem.length) == entityPath.fileSystem
|
# in the destination folder
|
||||||
if isNestedFolder
|
ProjectEntityHandler.checkElementName destEntity, entity.name, (err)->
|
||||||
callback(new Error("destination folder is a child folder of me"))
|
return callback(err) if err?
|
||||||
else
|
if entityType.match(/folder/)
|
||||||
|
logger.log destFolderPath: destFolderPath.fileSystem, folderPath: entityPath.fileSystem, "checking folder is not moving into child folder"
|
||||||
|
isNestedFolder = destFolderPath.fileSystem.slice(0, entityPath.fileSystem.length) == entityPath.fileSystem
|
||||||
|
if isNestedFolder
|
||||||
|
return callback(new Error("destination folder is a child folder of me"))
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
|
|
||||||
deleteEntity: (project_id, entity_id, entityType, userId, callback = (error) ->)->
|
deleteEntity: (project_id, entity_id, entityType, userId, callback = (error) ->)->
|
||||||
self = @
|
self = @
|
||||||
logger.log entity_id:entity_id, entityType:entityType, project_id:project_id, "deleting project entity"
|
logger.log entity_id:entity_id, entityType:entityType, project_id:project_id, "deleting project entity"
|
||||||
|
|
Loading…
Reference in a new issue