-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment
transform, with attachment.stub: true
support and tests
#97
Conversation
Unit test courtesy of Matt Marcum @mattmarcum
Ember.Object.create({ | ||
name: 'test.txt', | ||
content_type: 'text/plain', | ||
data: 'hello world!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically this should be base64-encoded (e.g. btoa('hello world')
). although I don't think it matters for the purpose of the test
I'd like to clarify a few points I have before moving on with implementation. It looks like there is no point in passing
The only case where having a |
Same as with |
@stevebest I think you might not have a clear picture of how stubs are used in P/CouchDB. Let me try to explain. (N.B.: I wrote most of PouchDB's attachment code. 😃) When you insert a document with revision When you update the document with revision However, if you tried to insert a stub with a digest that was not known by P/CouchDB (e.g. because the revision was compacted, or because of an error on your part), then P/CouchDB will throw a 412 error to indicate that it doesn't know what stub you're talking about. As for |
I like the use of a transformer to define an attachment type for Ember Data. I’m excited to have this merged! |
Huh, never saw a 412 from any of them. TIL. In any case, stub attachments seem to be a point of incompatibility between PouchDB and CouchDB. Couch happily accepts attachments which are nothing but |
@stevebest That might be a bug in CouchDB TBH. I don't know what it even means to push a stub of an attachment without a digest at least. The replicator and normal user operations (e.g. |
Unfortunately there are conflicts; I'm clearing out old issues/PRs, so please reopen if you have time to add those changes. I would be nervous about merging attachment support changes if I know that those changes might cause incompatibility issues with Couch/Pouch, sorry about that. |
@stevebest what's the status of this PR? We're looking to implement this and it'd be good to get your solution added to ember-pouch. I've merged your branch with upstream master in jtribe/ember-pouch and fixed the conflicts. Let me know if you want me to submit a PR to this branch or create a new PR. |
@nolanlawson can you please clarify if there's a problem that needs to be fixed with the way digests are handled in this PR. If so then some advice would be welcome. Judging from the Attachments guide on the PouchDB docs the digest is provided by CouchDB. Should we simply include the digest when we send document updates? |
Couch and Pouch both calculate digests when attachments are inserted, and those digests are usually the same (modulo some slight differences in how Couch handles Erlang strings compared to Pouch using JavaScript strings). IIRC my beef with this PR was just that |
Okay, thanks. Excuse my ignorance, but it's not clear what needs to be done to add them to the tests. |
So I took some time to rebase my fork against latest master, added support for preserving |
As promised in #92, finally.