Open vanniktech opened 3 months ago
Unfortunately the thing we need to read a zip FileSystem isn’t a Source (streaming) but rather a FileHandle (random access).
That makes sense. Does InputStream
have random access? If not, how is ZipInputStream
able to use an InputStream
?
ZipInputStream reads valid entries from the beginning of the stream through to the end. Only once at the end do you reach the central index and can realize that some of the entities you saw were not in the directory and thus were old/fake/malicious.
Still worth doing, in my opinion, as it has its uses too. Just gotta put a big caveat.
Counterpart of what I wrote here https://github.com/square/okio/issues/1442#issuecomment-2024801707
When the user is choosing for instance on Android from the file picker a file, I can get an
InputStream
quite easily. Which I can also callsource()
on but from there I don't get an easy way of reading it as a zip file. I could as a workaround write it to a file and then callopenZip()
but I think it's beneficial to have areadZip()
directly on aSource
so that any source is readable as a Zip.