mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 05:11:34 +02:00
Rename flush param to skip_flush in delete doc
Also move it to the query string instead of the body.
This commit is contained in:
@@ -106,10 +106,21 @@ module.exports = HttpController =
|
||||
deleteDoc: (req, res, next = (error) ->) ->
|
||||
doc_id = req.params.doc_id
|
||||
project_id = req.params.project_id
|
||||
flush = req.body.flush ? true
|
||||
logger.log project_id: project_id, doc_id: doc_id, flush: flush, "deleting doc via http"
|
||||
skip_flush = req.query.skip_flush == 'true'
|
||||
timer = new Metrics.Timer("http.deleteDoc")
|
||||
if flush
|
||||
if skip_flush
|
||||
logger.log project_id: project_id, doc_id: doc_id, "deleting doc skipping flush via http (contents may be lost)"
|
||||
|
||||
# Warning: This action is destructive. Skipping the flush will lose
|
||||
# contents that have not been flushed yet. Use this to fix a document in a
|
||||
# bad state that can't be flushed anyway.
|
||||
DocumentManager.deleteDocWithLock project_id, doc_id, (error) ->
|
||||
timer.done()
|
||||
return next(error) if error?
|
||||
logger.log project_id: project_id, doc_id: doc_id, "deleted doc via http"
|
||||
res.send 204 # No Content
|
||||
else
|
||||
logger.log project_id: project_id, doc_id: doc_id, "deleting doc via http"
|
||||
DocumentManager.flushAndDeleteDocWithLock project_id, doc_id, (error) ->
|
||||
timer.done()
|
||||
# There is no harm in flushing project history if the previous call
|
||||
@@ -119,12 +130,6 @@ module.exports = HttpController =
|
||||
return next(error) if error?
|
||||
logger.log project_id: project_id, doc_id: doc_id, "deleted doc via http"
|
||||
res.send 204 # No Content
|
||||
else
|
||||
DocumentManager.deleteDocWithLock project_id, doc_id, (error) ->
|
||||
timer.done()
|
||||
return next(error) if error?
|
||||
logger.log project_id: project_id, doc_id: doc_id, "deleted doc via http"
|
||||
res.send 204 # No Content
|
||||
|
||||
flushProject: (req, res, next = (error) ->) ->
|
||||
project_id = req.params.project_id
|
||||
@@ -212,7 +217,7 @@ module.exports = HttpController =
|
||||
|
||||
flushAllProjects: (req, res, next = (error)-> )->
|
||||
res.setTimeout(5 * 60 * 1000)
|
||||
options =
|
||||
options =
|
||||
limit : req.query.limit || 1000
|
||||
concurrency : req.query.concurrency || 5
|
||||
dryRun : req.query.dryRun || false
|
||||
@@ -225,7 +230,7 @@ module.exports = HttpController =
|
||||
|
||||
flushQueuedProjects: (req, res, next = (error) ->) ->
|
||||
res.setTimeout(10 * 60 * 1000)
|
||||
options =
|
||||
options =
|
||||
limit : req.query.limit || 1000
|
||||
timeout: 5 * 60 * 1000
|
||||
min_delete_age: req.query.min_delete_age || 5 * 60 * 1000
|
||||
|
||||
@@ -271,7 +271,7 @@ describe "HttpController", ->
|
||||
params:
|
||||
project_id: @project_id
|
||||
doc_id: @doc_id
|
||||
body: {}
|
||||
query: {}
|
||||
|
||||
describe "successfully", ->
|
||||
beforeEach ->
|
||||
@@ -295,7 +295,7 @@ describe "HttpController", ->
|
||||
|
||||
it "should log the request", ->
|
||||
@logger.log
|
||||
.calledWith(doc_id: @doc_id, project_id: @project_id, flush: true, "deleting doc via http")
|
||||
.calledWith(doc_id: @doc_id, project_id: @project_id, "deleting doc via http")
|
||||
.should.equal true
|
||||
|
||||
it "should time the request", ->
|
||||
@@ -303,7 +303,7 @@ describe "HttpController", ->
|
||||
|
||||
describe "without flush", ->
|
||||
beforeEach ->
|
||||
@req.body.flush = false
|
||||
@req.query.skip_flush = 'true'
|
||||
@DocumentManager.deleteDocWithLock = sinon.stub().yields()
|
||||
@HttpController.deleteDoc(@req, @res, @next)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user