You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/07/31 16:56:01 UTC
[couchdb] 11/34: Convert attachment info to disk terms correctly
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit bc8007b7018054733644805cdc430983bc2f4e73
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Jun 7 16:12:28 2019 -0500
Convert attachment info to disk terms correctly
I was accidentally skipping this step around properly
serializing/deserializing attachments.
Note to self: If someon specifies attachment headers this will likely
break when we attempt to pack the value tuple here.
---
src/fabric/src/fabric2_fdb.erl | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 788bbc6..4f08d97 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -926,14 +926,19 @@ doc_to_fdb(Db, #doc{} = Doc) ->
deleted = Deleted
} = Doc,
+ DiskAtts = lists:map(fun couch_att:to_disk_term/1, Atts),
+
Key = erlfdb_tuple:pack({?DB_DOCS, Id, Start, Rev}, DbPrefix),
- Val = {Body, Atts, Deleted},
+ Val = {Body, DiskAtts, Deleted},
{Key, term_to_binary(Val, [{minor_version, 1}])}.
-fdb_to_doc(_Db, DocId, Pos, Path, Bin) when is_binary(Bin) ->
- {Body, Atts, Deleted} = binary_to_term(Bin, [safe]),
- #doc{
+fdb_to_doc(Db, DocId, Pos, Path, Bin) when is_binary(Bin) ->
+ {Body, DiskAtts, Deleted} = binary_to_term(Bin, [safe]),
+ Atts = lists:map(fun(Att) ->
+ couch_att:from_disk_term(Db, DocId, Att)
+ end, DiskAtts),
+ Doc0 = #doc{
id = DocId,
revs = {Pos, Path},
body = Body,