You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/05/05 22:06:48 UTC

[couchdb] branch encapsulate-md5-bits-in-couch-file created (now 2a90188bd)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch encapsulate-md5-bits-in-couch-file
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at 2a90188bd Encapsulate MD5 file checksums bits in couch_file

This branch includes the following new commits:

     new 2a90188bd Encapsulate MD5 file checksums bits in couch_file

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Encapsulate MD5 file checksums bits in couch_file

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch encapsulate-md5-bits-in-couch-file
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2a90188bd63482b88507a85da09702113ad72d20
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Fri May 5 18:05:43 2023 -0400

    Encapsulate MD5 file checksums bits in couch_file
    
    Avoid leaking checksumming details into couch_bt_engine.
---
 src/couch/src/couch_bt_engine.erl | 3 +--
 src/couch/src/couch_file.erl      | 5 +++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl
index 0549de566..e5b7749f3 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -421,8 +421,7 @@ serialize_doc(#st{} = St, #doc{} = Doc) ->
     Body = Compress(Doc#doc.body),
     Atts = Compress(Doc#doc.atts),
     SummaryBin = ?term_to_bin({Body, Atts}),
-    Md5 = couch_hash:md5_hash(SummaryBin),
-    Data = couch_file:assemble_file_chunk(SummaryBin, Md5),
+    Data = couch_file:assemble_file_chunk_and_checksum(SummaryBin),
     % TODO: This is a terrible hack to get around the issues
     %       in COUCHDB-3255. We'll need to come back and figure
     %       out a better approach to handling the case when we
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index ba8d9c42f..514d4e3d9 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -40,7 +40,7 @@
 -export([open/1, open/2, close/1, bytes/1, sync/1, truncate/2, set_db_pid/2]).
 -export([pread_term/2, pread_iolist/2, pread_binary/2]).
 -export([append_binary/2]).
--export([append_raw_chunk/2, assemble_file_chunk/2]).
+-export([append_raw_chunk/2, assemble_file_chunk_and_checksum/1]).
 -export([append_term/2, append_term/3]).
 -export([pread_terms/2]).
 -export([append_terms/2, append_terms/3]).
@@ -141,7 +141,8 @@ append_raw_chunk(Fd, Chunk) ->
 assemble_file_chunk(Bin) ->
     [<<0:1/integer, (iolist_size(Bin)):31/integer>>, Bin].
 
-assemble_file_chunk(Bin, Md5) ->
+assemble_file_chunk_and_checksum(Bin) ->
+    Md5 = couch_hash:md5_hash(Bin),
     [<<1:1/integer, (iolist_size(Bin)):31/integer>>, Md5, Bin].
 
 %%----------------------------------------------------------------------