diff options
author | Adam Kocoloski <adam@cloudant.com> | 2010-07-28 15:10:21 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2010-07-28 17:33:20 -0400 |
commit | f8c3d90e660d1f1bd4b65c7cacb6f7e748ce951e (patch) | |
tree | 4e15917a353c394ef25a61312d28895531128374 /src | |
parent | 33ee9064a3434baef7b5f026c8e41b563ac8d5e0 (diff) |
preliminary support for multipart/related PUTs with N>1
Diffstat (limited to 'src')
-rw-r--r-- | src/fabric_rpc.erl | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl index e1bd6831..f56e3f68 100644 --- a/src/fabric_rpc.erl +++ b/src/fabric_rpc.erl @@ -191,13 +191,14 @@ get_missing_revs(DbName, IdRevsList) -> Error end). -update_docs(DbName, Docs, Options) -> +update_docs(DbName, Docs0, Options) -> case proplists:get_value(replicated_changes, Options) of true -> X = replicated_changes; _ -> X = interactive_edit end, + Docs = make_att_readers(Docs0), with_db(DbName, Options, {couch_db, update_docs, [Docs, Options, X]}). group_info(DbName, Group0) -> @@ -369,3 +370,19 @@ possible_ancestors(FullInfo, MissingRevs) -> Acc end end, [], LeafRevs). + +make_att_readers([]) -> + []; +make_att_readers([#doc{atts=Atts0} = Doc | Rest]) -> + % % go through the attachments looking for 'follows' in the data, + % % replace with function that reads the data from MIME stream. + Atts = [Att#att{data=make_att_reader(D)} || #att{data=D} = Att <- Atts0], + [Doc#doc{atts = Atts} | make_att_readers(Rest)]. + +make_att_reader({follows, Parser}) -> + fun() -> + Parser ! {get_bytes, self()}, + receive {bytes, Bytes} -> Bytes end + end; +make_att_reader(Else) -> + Else. |