Deferred attachment download issue with sync gateway

We made a change in couchbase lite that fixed issues with deferred download of attachments. This is mostly working in production, except for one issue we have come across. Here are the steps…

  1. Pull from server, but don’t download attachments
  2. Change a document locally (but do not push changes)
  3. Attempt to download attachment on changed document

Step 3 fails with 404 missing as the revision id is unknown to sync gateway. It seems that in this circumstance that sync gateway should return the attachment for the last known revision. We made a quick change to validate this works. Any thoughts on whether this is the right approach?

It seems reasonable to me that in the case that the client does not have an attachment and asks the server then the best the server can do is return the attachment for the latest revision.

I just opened github issue 2621 and am planning to discuss w/ the rest of the Sync Gateway team. Can you put up a PR for your change and reference the github issue?

Thanks for your contribution!