Error if update would make document too long

This commit is contained in:
James Allen 2015-11-06 12:52:03 +00:00
parent 03e9d7390f
commit e73890bfc2
3 changed files with 6 additions and 1 deletions

View file

@ -15,7 +15,7 @@ ShareJsModel:: = {}
util.inherits ShareJsModel, EventEmitter
module.exports = ShareJsUpdateManager =
getNewShareJsModel: () -> new ShareJsModel(ShareJsDB)
getNewShareJsModel: () -> new ShareJsModel(ShareJsDB, maxDocLength: Settings.max_doc_length)
applyUpdates: (project_id, doc_id, updates, callback = (error, updatedDocLines) ->) ->
logger.log project_id: project_id, doc_id: doc_id, updates: updates, "applying sharejs updates"

View file

@ -136,6 +136,9 @@ module.exports = Model = (db, options) ->
catch error
console.error error.stack
return callback error.message
if options.maxDocLength? and doc.snapshot.length > options.maxDocLength
return callback "Update takes doc over max doc size"
# The op data should be at the current version, and the new document data should be at
# the next version.

View file

@ -23,6 +23,8 @@ module.exports =
zip:
minSize: 10*1024
writesEnabled: false
max_doc_length: 2 * 1024 * 1024 # 2mb
mongo:
url: 'mongodb://127.0.0.1/sharelatex'