summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_db_updater.erl4
-rw-r--r--src/couchdb/couch_doc.erl6
-rw-r--r--src/couchdb/couch_stream.erl3
3 files changed, 9 insertions, 4 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index db5c43bc..7292221a 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -704,6 +704,10 @@ copy_doc_attachments(#db{fd=SrcFd}=SrcDb, {Pos,_RevId}, SrcSp, DestFd) ->
% 09 UPGRADE CODE
{NewBinSp, Len, Md5} = couch_stream:copy_to_new_stream(SrcFd, BinSp, DestFd),
{Name, Type, NewBinSp, Len, Pos, Md5};
+ ({Name, Type, BinSp, Len, RevPos, <<>>}) when is_tuple(BinSp) orelse BinSp == null ->
+ % 09 UPGRADE CODE
+ {NewBinSp, Len, Md5} = couch_stream:old_copy_to_new_stream(SrcFd, BinSp, Len, DestFd),
+ {Name, Type, NewBinSp, Len, Len, Md5};
({Name, Type, BinSp, Len, RevPos, Md5}) ->
{NewBinSp, Len, Md5} = couch_stream:copy_to_new_stream(SrcFd, BinSp, DestFd),
{Name, Type, NewBinSp, Len, RevPos, Md5}
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index d0c2918a..bdefb95c 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -285,9 +285,9 @@ att_to_iolist(#att{data=Bin}) when is_binary(Bin) ->
Bin;
att_to_iolist(#att{data=Iolist}) when is_list(Iolist) ->
Iolist;
-att_to_iolist(#att{data={Fd,Sp},md5=Md5}) ->
- lists:reverse(couch_stream:foldl(Fd, Sp, Md5,
- fun(Bin,Acc) -> [Bin|Acc] end, []));
+att_to_iolist(#att{data={Fd,Sp}}=Att) ->
+ lists:reverse(att_foldl(Att,
+ fun(Bin,Acc) -> [Bin|Acc] end, []));
att_to_iolist(#att{data=DataFun, len=Len}) when is_function(DataFun)->
lists:reverse(fold_streamed_data(DataFun, Len,
fun(Data, Acc) -> [Data | Acc] end, [])).
diff --git a/src/couchdb/couch_stream.erl b/src/couchdb/couch_stream.erl
index 65cf7126..2a873e4c 100644
--- a/src/couchdb/couch_stream.erl
+++ b/src/couchdb/couch_stream.erl
@@ -73,7 +73,8 @@ old_copy_to_new_stream(Fd, Pos, Len, DestFd) ->
old_foldl(_Fd, null, 0, _Fun, Acc) ->
Acc;
old_foldl(Fd, OldPointer, Len, Fun, Acc) when is_tuple(OldPointer)->
- old_stream_data(Fd, OldPointer, Len, ?DEFAULT_STREAM_CHUNK, Fun, Acc).
+ {ok, Acc2, _} = old_stream_data(Fd, OldPointer, Len, ?DEFAULT_STREAM_CHUNK, Fun, Acc),
+ Acc2.
foldl(_Fd, [], _Fun, Acc) ->
Acc;