mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
check if doc is missing from DocsIn set
This commit is contained in:
parent
fa089dc28d
commit
bed64d26c8
2 changed files with 12 additions and 1 deletions
|
@ -113,6 +113,16 @@ module.exports = RedisManager =
|
||||||
if doc_project_id? and doc_project_id isnt project_id
|
if doc_project_id? and doc_project_id isnt project_id
|
||||||
logger.error project_id: project_id, doc_id: doc_id, doc_project_id: doc_project_id, "doc not in project"
|
logger.error project_id: project_id, doc_id: doc_id, doc_project_id: doc_project_id, "doc not in project"
|
||||||
return callback(new Errors.NotFoundError("document not found"))
|
return callback(new Errors.NotFoundError("document not found"))
|
||||||
|
|
||||||
|
# doc is not in redis, bail out
|
||||||
|
if !lines?
|
||||||
|
return callback null, docLines, version, ranges
|
||||||
|
|
||||||
|
# doc should be in project set, check if missing (workaround for missing docs from putDoc)
|
||||||
|
rclient.sadd keys.docsInProject(project_id:project_id), doc_id, (error, result) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
if result isnt 0 # doc should already be in set
|
||||||
|
logger.error project_id: project_id, doc_id: doc_id, doc_project_id: doc_project_id, "doc missing from docsInProject set"
|
||||||
callback null, docLines, version, ranges
|
callback null, docLines, version, ranges
|
||||||
|
|
||||||
getDocVersion: (doc_id, callback = (error, version) ->) ->
|
getDocVersion: (doc_id, callback = (error, version) ->) ->
|
||||||
|
|
|
@ -58,6 +58,7 @@ describe "RedisManager", ->
|
||||||
@json_ranges = JSON.stringify @ranges
|
@json_ranges = JSON.stringify @ranges
|
||||||
@rclient.get = sinon.stub()
|
@rclient.get = sinon.stub()
|
||||||
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @hash, @project_id, @json_ranges])
|
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonlines, @version, @hash, @project_id, @json_ranges])
|
||||||
|
@rclient.sadd = sinon.stub().yields()
|
||||||
|
|
||||||
describe "successfully", ->
|
describe "successfully", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue