diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-06-07 16:12:28 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-07-31 11:55:30 -0500 |
commit | bc8007b7018054733644805cdc430983bc2f4e73 (patch) | |
tree | 2fb4afdbf6a4452b24e812c34ac4d885e7168ddd | |
parent | 1876962db1e7c1c61696dda241c35c071215244d (diff) | |
download | couchdb-bc8007b7018054733644805cdc430983bc2f4e73.tar.gz |
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.
-rw-r--r-- | src/fabric/src/fabric2_fdb.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index 788bbc62a..4f08d971a 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, |