mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Only call getFileStream callback once
This commit is contained in:
parent
eb40dbbe96
commit
45689fd2b8
1 changed files with 6 additions and 1 deletions
|
@ -27,7 +27,10 @@ module.exports =
|
|||
return callback err
|
||||
@sendFile location, target, fsPath, callback
|
||||
|
||||
getFileStream: (location, name, callback = (err, res)->)->
|
||||
getFileStream: (location, name, _callback = (err, res)->) ->
|
||||
callback = (args...) ->
|
||||
_callback(args...)
|
||||
_callback = () ->
|
||||
filteredName = filterName name
|
||||
logger.log location:location, name:filteredName, "getting file"
|
||||
sourceStream = fs.createReadStream "#{location}/#{filteredName}"
|
||||
|
@ -38,6 +41,8 @@ module.exports =
|
|||
else
|
||||
callback err
|
||||
sourceStream.on 'readable', () ->
|
||||
# This can be called multiple times, but the callback wrapper
|
||||
# ensures the callback is only called once
|
||||
callback null, sourceStream
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue