Files
fizzy/app/models/zip_file/reader/extractor_io.rb
T
Stanko K.R. 5bbd7f633d Process everything in chunks
The old implementation loaded files into memory to provide an IO interface. This has the obvious downside of loading any file included in the import, e.g. a 10GB video file, into memory. ZipKit has no native IO object for reading but it provides all the necessary methods to implement one.
2026-02-02 12:36:48 +01:00

24 lines
368 B
Ruby

class ZipFile::Reader::ExtractorIO
def initialize(extractor)
@extractor = extractor
end
def read(length = nil, buffer = nil)
return nil if @extractor.eof?
data = @extractor.extract(length)
return nil if data.nil?
if buffer
buffer.replace(data)
buffer
else
data
end
end
def eof?
@extractor.eof?
end
end