couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [07/25] couch commit: updated refs/heads/master to 92598cd
Date Thu, 15 Oct 2015 16:35:41 GMT
Extract decode_attributes frunction from doc_to_multi_part_stream


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/0a2e3129
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/0a2e3129
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/0a2e3129

Branch: refs/heads/master
Commit: 0a2e312932f488eb74e16b87f910dee5175d091a
Parents: 5618ad9
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Nov 28 13:07:01 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed May 6 06:55:58 2015 -0700

----------------------------------------------------------------------
 src/couch_doc.erl | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/0a2e3129/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index 082641c..96945e6 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -408,7 +408,16 @@ len_doc_to_multi_part_stream(Boundary, JsonBytes, Atts, SendEncodedAtts)
->
 doc_to_multi_part_stream(Boundary, JsonBytes, Atts, WriteFun,
     SendEncodedAtts) ->
     AttsToInclude = lists:filter(fun(Att)-> couch_att:fetch(data, Att) /= stub end, Atts),
-    AttsDecoded = lists:map(fun(Att) ->
+    AttsDecoded = decode_attributes(AttsToInclude, SendEncodedAtts),
+    AttFun = case SendEncodedAtts of
+        false -> fun couch_att:foldl_decode/3;
+        true  -> fun couch_att:foldl/3
+    end,
+    couch_httpd_multipart:encode_multipart_stream(
+      Boundary, JsonBytes, AttsDecoded, WriteFun, AttFun).
+
+decode_attributes(Atts, SendEncodedAtts) ->
+    lists:map(fun(Att) ->
         [Name, AttLen, DiskLen, Type, Encoding] =
            couch_att:fetch([name, att_len, disk_len, type, encoding], Att),
         Len = case SendEncodedAtts of
@@ -416,13 +425,7 @@ doc_to_multi_part_stream(Boundary, JsonBytes, Atts, WriteFun,
             false -> list_to_binary(integer_to_list(DiskLen))
           end,
         {Att, Name, Len, Type, Encoding}
-      end, AttsToInclude),
-    AttFun = case SendEncodedAtts of
-        false -> fun couch_att:foldl_decode/3;
-        true  -> fun couch_att:foldl/3
-    end,
-    couch_httpd_multipart:encode_multipart_stream(
-      Boundary, JsonBytes, AttsDecoded, WriteFun, AttFun).
+      end, Atts).
 
 doc_from_multi_part_stream(ContentType, DataFun) ->
     doc_from_multi_part_stream(ContentType, DataFun, make_ref()).


Mime
View raw message