Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Restore R14 compatibility
CouchDB 2.0 will be compatible with R14. Support for R14 to be dropped
after.

closes COUCHDB-2755
  • Loading branch information
rnewson committed Jul 22, 2015
1 parent 822f3a2 commit fe02b297131849f9d6ccbf7ac735c09f63ec5c32
Showing 2 changed files with 11 additions and 3 deletions.
@@ -178,7 +178,7 @@ read({file, FilePath}) ->

hash_of_file(FilePath) ->
{ok, Data} = file:read_file(FilePath),
crypto:hash(md5, Data).
couch_epi_util:md5(Data).

current(Handle, Subscriber) ->
try
@@ -12,13 +12,21 @@

-module(couch_epi_util).

-export([module_version/1, hash/1]).
-export([module_version/1, hash/1, md5/1]).

module_version(Module) ->
Attributes = Module:module_info(attributes),
{vsn, VSNs} = lists:keyfind(vsn, 1, Attributes),
VSNs.

hash(Term) ->
<<SigInt:128/integer>> = crypto:hash(md5, term_to_binary(Term)),
<<SigInt:128/integer>> = md5(term_to_binary(Term)),
io_lib:format("\"~.36B\"",[SigInt]).

md5(Data) ->
case erlang:function_exported(crypto, hash, 2) of
true ->
crypto:hash(md5, Data);
false ->
crypto:md5(Data)
end.

0 comments on commit fe02b29

Please sign in to comment.