Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit bf89f28

Browse files
committed
Include meta randomness when generating new rev id
COUCHDB-3314
1 parent 016e1aa commit bf89f28

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/couch_db.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ prep_and_validate_replicated_updates(Db, [Bucket|RestBuckets], [OldInfo|RestOldI
860860

861861

862862

863-
new_revid(#doc{body=Body0, revs={OldStart,OldRevs}, atts=Atts, deleted=Deleted}) ->
863+
new_revid(#doc{body=Body0, revs={OldStart,OldRevs}, atts=Atts, deleted=Deleted, meta=Meta}=Doc) ->
864864
DigestedAtts = lists:foldl(fun(Att, Acc) ->
865865
[N, T, M] = couch_att:fetch([name, type, md5], Att),
866866
case M == <<>> of
@@ -883,7 +883,8 @@ new_revid(#doc{body=Body0, revs={OldStart,OldRevs}, atts=Atts, deleted=Deleted})
883883
% We must have old style non-md5 attachments
884884
?l2b(integer_to_list(couch_util:rand32()));
885885
Atts2 ->
886-
OldRev = case OldRevs of [] -> 0; [OldRev0|_] -> OldRev0 end,
886+
Rnd = couch_util:get_value(rnd, Meta),
887+
OldRev = case OldRevs of [] -> Rnd; [OldRev0|_] -> OldRev0 end,
887888
couch_crypto:hash(md5, term_to_binary([Deleted, OldStart, OldRev, Body, Atts2], [{minor_version, 1}]))
888889
end.
889890

0 commit comments

Comments
 (0)