mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
refactor addFile and addFileWithOutUpdatingHistory
This commit is contained in:
parent
d949338ed4
commit
fe8897d757
1 changed files with 20 additions and 19 deletions
|
@ -153,6 +153,15 @@ module.exports = ProjectEntityUpdateHandler = self =
|
||||||
return callback(err)
|
return callback(err)
|
||||||
callback(null, fileRef, fileStoreUrl)
|
callback(null, fileRef, fileStoreUrl)
|
||||||
|
|
||||||
|
_addFileAndSendToTpds: (project_id, folder_id, fileName, fileRef, callback = (error) ->)->
|
||||||
|
ProjectEntityMongoUpdateHandler.addFile project_id, folder_id, fileRef, (err, result, project) ->
|
||||||
|
if err?
|
||||||
|
logger.err err:err, project_id: project_id, folder_id: folder_id, file_name: fileName, fileRef:fileRef, "error adding file with project"
|
||||||
|
return callback(err)
|
||||||
|
TpdsUpdateSender.addFile {project_id:project_id, file_id:fileRef._id, path:result?.path?.fileSystem, project_name:project.name, rev:fileRef.rev}, (err) ->
|
||||||
|
return callback(err) if err?
|
||||||
|
callback(null, result, project)
|
||||||
|
|
||||||
addFile: wrapWithLock
|
addFile: wrapWithLock
|
||||||
beforeLock: (next) ->
|
beforeLock: (next) ->
|
||||||
(project_id, folder_id, fileName, fsPath, linkedFileData, userId, callback) ->
|
(project_id, folder_id, fileName, fsPath, linkedFileData, userId, callback) ->
|
||||||
|
@ -160,20 +169,16 @@ module.exports = ProjectEntityUpdateHandler = self =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
next(project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback)
|
next(project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback)
|
||||||
withLock: (project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback = (error, fileRef, folder_id) ->)->
|
withLock: (project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback = (error, fileRef, folder_id) ->)->
|
||||||
ProjectEntityMongoUpdateHandler.addFile project_id, folder_id, fileRef, (err, result, project) ->
|
ProjectEntityUpdateHandler._addFileAndSendToTpds project_id, folder_id, fileName, fileRef, (err, result, project) ->
|
||||||
if err?
|
return callback(err) if err?
|
||||||
logger.err err:err, project_id: project_id, folder_id: folder_id, file_name: fileName, fileRef:fileRef, "error adding file with project"
|
newFiles = [
|
||||||
return callback(err)
|
file: fileRef
|
||||||
TpdsUpdateSender.addFile {project_id:project_id, file_id:fileRef._id, path:result?.path?.fileSystem, project_name:project.name, rev:fileRef.rev}, (err) ->
|
path: result?.path?.fileSystem
|
||||||
return callback(err) if err?
|
url: fileStoreUrl
|
||||||
newFiles = [
|
]
|
||||||
file: fileRef
|
DocumentUpdaterHandler.updateProjectStructure project_id, userId, {newFiles}, (error) ->
|
||||||
path: result?.path?.fileSystem
|
return callback(error) if error?
|
||||||
url: fileStoreUrl
|
callback(null, fileRef, folder_id, result?.path?.fileSystem, fileStoreUrl)
|
||||||
]
|
|
||||||
DocumentUpdaterHandler.updateProjectStructure project_id, userId, {newFiles}, (error) ->
|
|
||||||
return callback(error) if error?
|
|
||||||
callback(null, fileRef, folder_id, result?.path?.fileSystem, fileStoreUrl)
|
|
||||||
|
|
||||||
replaceFile: wrapWithLock
|
replaceFile: wrapWithLock
|
||||||
beforeLock: (next) ->
|
beforeLock: (next) ->
|
||||||
|
@ -228,11 +233,7 @@ module.exports = ProjectEntityUpdateHandler = self =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
next(project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback)
|
next(project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback)
|
||||||
withLock: (project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback = (error, fileRef, folder_id, path, fileStoreUrl) ->)->
|
withLock: (project_id, folder_id, fileName, fsPath, linkedFileData, userId, fileRef, fileStoreUrl, callback = (error, fileRef, folder_id, path, fileStoreUrl) ->)->
|
||||||
ProjectEntityMongoUpdateHandler.addFile project_id, folder_id, fileRef, (err, result, project) ->
|
ProjectEntityUpdateHandler._addFileAndSendToTpds project_id, folder_id, fileName, fileRef, (err, result, project) ->
|
||||||
if err?
|
|
||||||
logger.err err:err, project_id: project_id, folder_id: folder_id, file_name: fileName, fileRef:fileRef, "error adding file with project"
|
|
||||||
return callback(err)
|
|
||||||
TpdsUpdateSender.addFile {project_id:project_id, file_id:fileRef._id, path:result?.path?.fileSystem, project_name:project.name, rev:fileRef.rev}, (err) ->
|
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
callback(null, fileRef, folder_id, result?.path?.fileSystem, fileStoreUrl)
|
callback(null, fileRef, folder_id, result?.path?.fileSystem, fileStoreUrl)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue