diff --git a/lib/mini_mime.rb b/lib/mini_mime.rb index 566a5b1..b6d5dfa 100644 --- a/lib/mini_mime.rb +++ b/lib/mini_mime.rb @@ -50,8 +50,6 @@ def binary? end class Db - LOCK = Mutex.new - def self.lookup_by_filename(filename) extension = File.extname(filename) return if extension.empty? @@ -60,18 +58,14 @@ def self.lookup_by_filename(filename) end def self.lookup_by_extension(extension) - LOCK.synchronize do - @db ||= new - @db.lookup_by_extension(extension) || - @db.lookup_by_extension(extension.downcase) - end + @db ||= new + @db.lookup_by_extension(extension) || + @db.lookup_by_extension(extension.downcase) end def self.lookup_by_content_type(content_type) - LOCK.synchronize do - @db ||= new - @db.lookup_by_content_type(content_type) - end + @db ||= new + @db.lookup_by_content_type(content_type) end class Cache @@ -146,8 +140,7 @@ def lookup_uncached(val) end def resolve(row) - @file.seek(row * @row_length) - Info.new(@file.readline) + Info.new(@file.pread(@row_length, row * @row_length).force_encoding(Encoding::UTF_8)) end end diff --git a/test/fixtures/custom_content_type_mime.db b/test/fixtures/custom_content_type_mime.db index 0df3883..9e3cb70 100644 --- a/test/fixtures/custom_content_type_mime.db +++ b/test/fixtures/custom_content_type_mime.db @@ -1,2 +1,2 @@ -liquid application/x-liquid 8bit +liquid application/x-liquid 8bit mp4 video/vnd.objectvideo quoted-printable diff --git a/test/fixtures/custom_ext_mime.db b/test/fixtures/custom_ext_mime.db index 2147a75..cc3c2d6 100644 --- a/test/fixtures/custom_ext_mime.db +++ b/test/fixtures/custom_ext_mime.db @@ -1,2 +1,2 @@ -lua application/x-lua 8bit +lua application/x-lua 8bit m4v video/vnd.objectvideo quoted-printable