Make remote IOs rewindable
This is required for active storage to work
This commit is contained in:
@@ -9,12 +9,10 @@ class ZipFile::Reader
|
||||
raise ArgumentError, "File not found in zip: #{file_path}" unless entry
|
||||
raise ArgumentError, "Cannot read directory entry: #{file_path}" if entry.filename.end_with?("/")
|
||||
|
||||
extractor = entry.extractor_from(@io)
|
||||
|
||||
if block_given?
|
||||
yield ZipFile::Reader::ExtractorIO.new(extractor)
|
||||
yield ZipFile::Reader::ExtractorIO.new(entry, @io)
|
||||
else
|
||||
extractor.extract
|
||||
entry.extractor_from(@io).extract
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class ZipFile::Reader::ExtractorIO
|
||||
def initialize(extractor)
|
||||
@extractor = extractor
|
||||
def initialize(entry, io)
|
||||
@entry = entry
|
||||
@io = io
|
||||
@extractor = @entry.extractor_from(@io)
|
||||
end
|
||||
|
||||
def read(length = nil, buffer = nil)
|
||||
@@ -20,4 +22,9 @@ class ZipFile::Reader::ExtractorIO
|
||||
def eof?
|
||||
@extractor.eof?
|
||||
end
|
||||
|
||||
def rewind
|
||||
@extractor = @entry.extractor_from(@io)
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user