mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
[web+document-updater] Allow appending to documents (#20745)
Co-authored-by: David Powell <david.powell@overleaf.com> GitOrigin-RevId: f66283926e7da3edf83ada9316c3a001287e1b42
This commit is contained in:
committed by
Copybot
co-authored by
David Powell
parent
52254b5695
commit
1063dabf33
@@ -144,6 +144,7 @@ function setDoc(req, res, next) {
|
||||
source,
|
||||
userId,
|
||||
undoing,
|
||||
true,
|
||||
(error, result) => {
|
||||
timer.done()
|
||||
if (error) {
|
||||
@@ -155,6 +156,35 @@ function setDoc(req, res, next) {
|
||||
)
|
||||
}
|
||||
|
||||
function appendToDoc(req, res, next) {
|
||||
const docId = req.params.doc_id
|
||||
const projectId = req.params.project_id
|
||||
const { lines, source, user_id: userId } = req.body
|
||||
const timer = new Metrics.Timer('http.appendToDoc')
|
||||
DocumentManager.appendToDocWithLock(
|
||||
projectId,
|
||||
docId,
|
||||
lines,
|
||||
source,
|
||||
userId,
|
||||
(error, result) => {
|
||||
timer.done()
|
||||
if (error instanceof Errors.FileTooLargeError) {
|
||||
logger.warn('refusing to append to file, it would become too large')
|
||||
return res.sendStatus(422)
|
||||
}
|
||||
if (error) {
|
||||
return next(error)
|
||||
}
|
||||
logger.debug(
|
||||
{ projectId, docId, lines, source, userId },
|
||||
'appending to doc via http'
|
||||
)
|
||||
res.json(result)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function flushDocIfLoaded(req, res, next) {
|
||||
const docId = req.params.doc_id
|
||||
const projectId = req.params.project_id
|
||||
@@ -460,6 +490,7 @@ module.exports = {
|
||||
peekDoc,
|
||||
getProjectDocsAndFlushIfOld,
|
||||
clearProjectState,
|
||||
appendToDoc,
|
||||
setDoc,
|
||||
flushDocIfLoaded,
|
||||
deleteDoc,
|
||||
|
||||
Reference in New Issue
Block a user