mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
18 lines
775 B
CoffeeScript
18 lines
775 B
CoffeeScript
MongoManager = require "./MongoManager"
|
|
UpdateCompressor = require "./UpdateCompressor"
|
|
logger = require "logger-sharelatex"
|
|
|
|
module.exports = HistoryManager =
|
|
compressAndSaveRawUpdates: (doc_id, rawUpdates, callback = (error) ->) ->
|
|
length = rawUpdates.length
|
|
if length == 0
|
|
return callback()
|
|
|
|
MongoManager.popLastCompressedUpdate doc_id, (error, lastCompressedUpdate) ->
|
|
return callback(error) if error?
|
|
compressedUpdates = UpdateCompressor.compressRawUpdates lastCompressedUpdate, rawUpdates
|
|
MongoManager.insertCompressedUpdates doc_id, compressedUpdates, (error) ->
|
|
return callback(error) if error?
|
|
logger.log doc_id: doc_id, rawUpdatesLength: length, compressedUpdatesLength: compressedUpdates.length, "compressed doc updates"
|
|
callback()
|
|
|