summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_db.erl
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-07-16 21:32:57 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-07-16 21:32:57 +0000
commitaa979801f94952acd558f7809417b40104846cfb (patch)
tree0370f6d9ab32850a8a0bdb698ddcce2a713e6f40 /src/couchdb/couch_db.erl
parent501e2bd5b85eb4df71e071e3df284df9bf36d92a (diff)
Fix for a pull replication, targeted to a 1.0 CouchDB server, where the source DB is in a remote CouchDB 0.11.0 server and the target DB is local (1.0 CouchDB DB).
Closes ticket COUCHDB-827. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@964956 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_db.erl')
-rw-r--r--src/couchdb/couch_db.erl16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 80f0d7bf..b445046f 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -901,10 +901,20 @@ with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) ->
write_streamed_attachment(_Stream, _F, 0) ->
ok;
+% LenLeft might be different from the total size of what function F returns.
+% This happens when doing a pull replication of compressed attachments from a
+% 0.11.0 server, where LenLeft will match the uncompressed size but we end up
+% receiving the attachment compressed (therefore a size different from LenLeft).
+% This is because 0.11.0 doesn't understand the query parameter
+% "?att_encoding_info=true" when we do a doc request (GET /somedb/somedoc).
write_streamed_attachment(Stream, F, LenLeft) ->
- Bin = F(),
- ok = couch_stream:write(Stream, Bin),
- write_streamed_attachment(Stream, F, LenLeft - size(Bin)).
+ case F() of
+ Bin when is_binary(Bin) ->
+ ok = couch_stream:write(Stream, Bin),
+ write_streamed_attachment(Stream, F, LenLeft - size(Bin));
+ eof ->
+ ok
+ end.
enum_docs_since_reduce_to_count(Reds) ->
couch_btree:final_reduce(