From 836bddd91fee8974bba4be2264c851b742caa966 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 9 Aug 2017 16:00:11 +0100 Subject: [PATCH] comment about 409 code in DocumentUpdaterHandler --- .../DocumentUpdater/DocumentUpdaterHandler.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee index 6064a41363..e3666ad9ef 100644 --- a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee +++ b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee @@ -124,6 +124,9 @@ module.exports = DocumentUpdaterHandler = callback new Error("doc updater returned a non-success status code: #{res.statusCode}") getProjectDocsIfMatch: (project_id, projectStateHash, callback = (error, docs) ->) -> + # If the project state hasn't changed, we can get all the latest + # docs from redis via the docupdater. Otherwise we will need to + # fall back to getting them from mongo. timer = new metrics.Timer("get-project-docs") url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc?state=#{projectStateHash}" logger.log project_id:project_id, "getting project docs from document updater" @@ -132,7 +135,12 @@ module.exports = DocumentUpdaterHandler = if error? logger.error err:error, url:url, project_id:project_id, "error getting project docs from doc updater" return callback(error) - if res.statusCode is 409 + if res.statusCode is 409 # HTTP response code "409 Conflict" + # Docupdater has checked the projectStateHash and found that + # it has changed. This means that the docs currently in redis + # aren't the only change to the project and the full set of + # docs/files should be retreived from docstore/filestore + # instead. return callback() else if res.statusCode >= 200 and res.statusCode < 300 logger.log project_id:project_id, "got project docs from document document updater"