couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r1054290 - in /couchdb/trunk/src/couchdb: couch_db.erl couch_util.erl
Date Sat, 01 Jan 2011 21:10:34 GMT
Author: benoitc
Date: Sat Jan  1 21:10:33 2011
New Revision: 1054290

URL: http://svn.apache.org/viewvc?rev=1054290&view=rev
Log:
remove cyclic dependancy. couch_config is using couch_util too.

Modified:
    couchdb/trunk/src/couchdb/couch_db.erl
    couchdb/trunk/src/couchdb/couch_util.erl

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1054290&r1=1054289&r2=1054290&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Sat Jan  1 21:10:33 2011
@@ -862,6 +862,24 @@ flush_att(Fd, #att{data=Fun,att_len=AttL
         write_streamed_attachment(OutputStream, Fun, AttLen)
     end).
 
+
+compressible_att_type(MimeType) when is_binary(MimeType) ->
+    compressible_att_type(?b2l(MimeType));
+compressible_att_type(MimeType) ->
+    TypeExpList = re:split(
+        couch_config:get("attachments", "compressible_types", ""),
+        ", ?",
+        [{return, list}]
+    ),
+    lists:any(
+        fun(TypeExp) ->
+            Regexp = ["^\\s*", re:replace(TypeExp, "\\*", ".*"),
+                "(?:\\s*;.*?)?\\s*", $$],
+            re:run(MimeType, Regexp, [caseless]) =/= nomatch
+        end,
+        [T || T <- TypeExpList, T /= []]
+    ).
+
 % From RFC 2616 3.6.1 - Chunked Transfer Coding
 %
 %   In other words, the origin server is willing to accept
@@ -874,7 +892,7 @@ flush_att(Fd, #att{data=Fun,att_len=AttL
 % pretend that no Content-MD5 exists.
 with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) ->
     {ok, OutputStream} = case (Enc =:= identity) andalso
-        couch_util:compressible_att_type(Type) of
+        compressible_att_type(Type) of
     true ->
         CompLevel = list_to_integer(
             couch_config:get("attachments", "compression_level", "0")

Modified: couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_util.erl?rev=1054290&r1=1054289&r2=1054290&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ couchdb/trunk/src/couchdb/couch_util.erl Sat Jan  1 21:10:33 2011
@@ -23,7 +23,6 @@
 -export([to_binary/1, to_integer/1, to_list/1, url_encode/1]).
 -export([json_encode/1, json_decode/1]).
 -export([verify/2,simple_call/2,shutdown_sync/1]).
--export([compressible_att_type/1]).
 -export([get_value/2, get_value/3]).
 -export([md5/1, md5_init/0, md5_update/2, md5_final/1]).
 -export([reorder_results/2]).
@@ -388,23 +387,6 @@ verify(X, Y) when is_list(X) and is_list
     end;
 verify(_X, _Y) -> false.
 
-compressible_att_type(MimeType) when is_binary(MimeType) ->
-    compressible_att_type(?b2l(MimeType));
-compressible_att_type(MimeType) ->
-    TypeExpList = re:split(
-        couch_config:get("attachments", "compressible_types", ""),
-        ", ?",
-        [{return, list}]
-    ),
-    lists:any(
-        fun(TypeExp) ->
-            Regexp = ["^\\s*", re:replace(TypeExp, "\\*", ".*"),
-                "(?:\\s*;.*?)?\\s*", $$],
-            re:run(MimeType, Regexp, [caseless]) =/= nomatch
-        end,
-        [T || T <- TypeExpList, T /= []]
-    ).
-
 -spec md5(Data::(iolist() | binary())) -> Digest::binary().
 md5(Data) ->
     try crypto:md5(Data) catch error:_ -> erlang:md5(Data) end.



Mime
View raw message