@@ -498,6 +498,27 @@ void main() {
498498 }
499499 });
500500
501+ test ('encode already compressed file' , () {
502+ final testArchive = Archive ();
503+ testArchive.addFile (ArchiveFile ('test' , 3 , [1 , 2 , 3 ])..compress = true );
504+ final testArchiveBytes =
505+ ZipEncoder ().encode (testArchive, level: Deflate .BEST_COMPRESSION )! ;
506+
507+ final decodedTestArchive = ZipDecoder ().decodeBytes (testArchiveBytes);
508+
509+ // Verify that the archive file is already compressed and will be
510+ // compressed when re-encoded.
511+ expect (decodedTestArchive.files.single.isCompressed, true );
512+ expect (decodedTestArchive.files.single.compressionType, 8 );
513+ expect (decodedTestArchive.files.single.compress, true );
514+
515+ final decodedTestArchiveBytes = ZipEncoder ()
516+ .encode (decodedTestArchive, level: Deflate .BEST_COMPRESSION )! ;
517+
518+ final verifyArchive = ZipDecoder ().decodeBytes (decodedTestArchiveBytes);
519+ expect (verifyArchive.single.content, [1 , 2 , 3 ]);
520+ });
521+
501522 test ('decode many files (100k)' , () {
502523 final fp = InputFileStream (
503524 p.join (testDirPath, 'res/test_100k_files.zip' ),
0 commit comments