mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
pause the stream of ops, not the download
the download is buffered in the lineStream so a lot comes out even after pausing the S3 download.
This commit is contained in:
parent
847a553344
commit
696a866b67
1 changed files with 5 additions and 4 deletions
|
@ -64,20 +64,21 @@ module.exports = MongoAWS =
|
||||||
ops = []
|
ops = []
|
||||||
sz = 0
|
sz = 0
|
||||||
|
|
||||||
download
|
inputStream = download
|
||||||
.on 'open', (obj) ->
|
.on 'open', (obj) ->
|
||||||
return 1
|
return 1
|
||||||
.on 'error', (err) ->
|
.on 'error', (err) ->
|
||||||
callback(err)
|
callback(err)
|
||||||
.pipe lineStream
|
.pipe lineStream
|
||||||
.on 'data', (line) ->
|
|
||||||
|
inputStream.on 'data', (line) ->
|
||||||
if line.length > 2
|
if line.length > 2
|
||||||
ops.push(JSON.parse(line))
|
ops.push(JSON.parse(line))
|
||||||
sz += line.length
|
sz += line.length
|
||||||
if ops.length >= MongoAWS.MAX_COUNT || sz >= MongoAWS.MAX_SIZE
|
if ops.length >= MongoAWS.MAX_COUNT || sz >= MongoAWS.MAX_SIZE
|
||||||
download.pause()
|
inputStream.pause()
|
||||||
MongoAWS.handleBulk ops.slice(0), sz, () ->
|
MongoAWS.handleBulk ops.slice(0), sz, () ->
|
||||||
download.resume()
|
inputStream.resume()
|
||||||
ops.splice(0,ops.length)
|
ops.splice(0,ops.length)
|
||||||
sz = 0
|
sz = 0
|
||||||
.on 'end', () ->
|
.on 'end', () ->
|
||||||
|
|
Loading…
Reference in a new issue