fetchers/tar: slight simplification

This commit is contained in:
Stephan Renatus 2016-02-22 11:23:49 +01:00 committed by Dominik Richter
parent c24a504cb6
commit 01d7d5bf8a

View file

@ -34,14 +34,10 @@ module Fetchers
def read_from_tar(file) def read_from_tar(file)
return nil unless @files.include?(file) return nil unless @files.include?(file)
res = nil res = nil
# NB `TarReader` includes `Enumerable` beginning with Ruby 2.x
Gem::Package::TarReader.new(Zlib::GzipReader.open(@target)) do |tar| Gem::Package::TarReader.new(Zlib::GzipReader.open(@target)) do |tar|
tar.each do |entry| tar.each do |entry|
next if entry.directory? next unless entry.file? && file == entry.full_name
# ignore symlinks for now
next if entry.header.typeflag == '2'
# only handle files for now
next unless entry.file?
next unless file == entry.full_name
res = entry.read res = entry.read
break break
end end