mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-13 17:57:10 +02:00
Merge pull request #74 from kou/improve-binary-file-detection
Improve binary file detection
This commit is contained in:
commit
a712acfa3a
@ -36,8 +36,7 @@ class FileReverseReader
|
||||
|
||||
def binary_file?
|
||||
sample = io.read(1024) || ""
|
||||
sample2 = sample.force_encoding('ascii-8bit').encode('us-ascii', :undef => :replace, :invalid => :replace, :replace => "")
|
||||
sample != sample2 # maybe binary file
|
||||
!sample.force_encoding('us-ascii').valid_encoding?
|
||||
ensure
|
||||
io.rewind
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user