archive icon indicating copy to clipboard operation
archive copied to clipboard

fix: add a listener interface to ZipDecoder to deal with large files

Open akkumar opened this issue 1 year ago • 0 comments

ZipDecoder contains a 'decodeBuffer' method to deal with (reasonably !!) large files by taking in a stream.

But to make it more complete , it should have a listener interface to deal with the files one at a time as opposed to uncompressing everything in memory (and running out of it ).

Of course, it is applicable only if the zip file is large and contains a bunch of relatively smaller individual files so they can be processed without bringing all of them into memory at once.

New type added:


/// FnArchiveFile is the callback invoked when the zip decoder iterates through the archive.
typedef FnArchiveFile = void Function(ArchiveFile file);

New method onDecodeBuffer added to ZipDecoder

  void onDecodeBuffer(
    InputStreamBase input,
    FnArchiveFile fnArchiveFile, {
    bool verify = false,
    String? password,
  }) ;

The above new method is very similar to the original decodeBuffer method , except that it takes a function ( FnArchiveFile ) as the second argument.

  Archive decodeBuffer(
    InputStreamBase input, {
    bool verify = false,
    String? password,
  }) 

This should address large files to some extent.

Let me know your comments regarding the same.

akkumar avatar Jul 26 '23 15:07 akkumar