Skip to content
Snippets Groups Projects
Commit af78b64d authored by Josh Hagins's avatar Josh Hagins Committed by GitHub
Browse files

Merge pull request #1258 from jawshooah/perf/keg-batch-text-files

keg_relocate: run /usr/bin/file in batches
parents 7a3ba923 d8a68632
No related branches found
No related tags found
No related merge requests found
......@@ -72,13 +72,14 @@ class Keg
# file with that fix is only available in macOS Sierra.
# http://bugs.gw.com/view.php?id=292
with_custom_locale("C") do
path.find do |pn|
next if pn.symlink? || pn.directory?
next if Metafiles::EXTENSIONS.include? pn.extname
if Utils.popen_read("/usr/bin/file", "--brief", pn).include?("text") ||
pn.text_executable?
text_files << pn
end
files = path.find.reject { |pn|
pn.symlink? || pn.directory? || Metafiles::EXTENSIONS.include?(pn.extname)
}
output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --brief",
stdin_data: files.join("\0"))
output.each_line.with_index do |line, i|
next unless line.include?("text")
text_files << files[i]
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment