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-06-10 14:50:51 -0500 |
commit | 09f4489533ee1976c3c683301dc7e1332b02bafb (patch) | |
tree | cb298505c81ddc516f091bd3dd6a021e17390257 | |
parent | e3f24aa1aa6eb389a0512670db0090cf03014506 (diff) | |
download | couchdb-09f4489533ee1976c3c683301dc7e1332b02bafb.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, |