mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 01:25:31 -05:00
always create a new pack, never keep as op
This commit is contained in:
parent
c6be12f3d5
commit
f592611cac
1 changed files with 1 additions and 12 deletions
|
@ -269,15 +269,10 @@ module.exports = PackManager =
|
||||||
|
|
||||||
MAX_SIZE: 1024*1024 # make these configurable parameters
|
MAX_SIZE: 1024*1024 # make these configurable parameters
|
||||||
MAX_COUNT: 1024
|
MAX_COUNT: 1024
|
||||||
MIN_COUNT: 100
|
|
||||||
KEEP_OPS: 100
|
|
||||||
|
|
||||||
convertDocsToPacks: (docs, callback) ->
|
convertDocsToPacks: (docs, callback) ->
|
||||||
packs = []
|
packs = []
|
||||||
top = null
|
top = null
|
||||||
# keep the last KEEP_OPS as individual ops
|
|
||||||
docs = docs.slice(0,-PackManager.KEEP_OPS)
|
|
||||||
|
|
||||||
docs.forEach (d,i) ->
|
docs.forEach (d,i) ->
|
||||||
# skip existing packs
|
# skip existing packs
|
||||||
if d.pack?
|
if d.pack?
|
||||||
|
@ -294,7 +289,7 @@ module.exports = PackManager =
|
||||||
top.v_end = d.v
|
top.v_end = d.v
|
||||||
top.meta.end_ts = d.meta.end_ts
|
top.meta.end_ts = d.meta.end_ts
|
||||||
return
|
return
|
||||||
else if sz < PackManager.MAX_SIZE
|
else
|
||||||
# create a new pack
|
# create a new pack
|
||||||
top = _.clone(d)
|
top = _.clone(d)
|
||||||
top.pack = [ {v: d.v, meta: d.meta, op: d.op, _id: d._id} ]
|
top.pack = [ {v: d.v, meta: d.meta, op: d.op, _id: d._id} ]
|
||||||
|
@ -304,13 +299,7 @@ module.exports = PackManager =
|
||||||
delete top.op
|
delete top.op
|
||||||
delete top._id
|
delete top._id
|
||||||
packs.push top
|
packs.push top
|
||||||
else
|
|
||||||
# keep the op
|
|
||||||
# util.log "keeping large op unchanged (#{sz} bytes)"
|
|
||||||
|
|
||||||
# only store packs with a sufficient number of ops, discard others
|
|
||||||
packs = packs.filter (packObj) ->
|
|
||||||
packObj.pack.length > PackManager.MIN_COUNT
|
|
||||||
callback(null, packs)
|
callback(null, packs)
|
||||||
|
|
||||||
checkHistory: (docs, callback) ->
|
checkHistory: (docs, callback) ->
|
||||||
|
|
Loading…
Reference in a new issue