#1 2015-11-10 21:57:59

ehansen
Member
Registered: 2015-11-10
Posts: 2

SynZip with Zero Length Files

Hello Synopse! I've been seeing the mORMot framework and AB's posts in google search results for quite some time now and I consistently like what I read, so I decided to start evaluating parts as I find places that pieces of the framework might be useful to my daily work.

I'm currently testing SynZip.Pas as a possible replacement for 7Zip's DLL in our applications.  We have a particular file format we use often which is nothing more than a ZIP file that we expect to contain particular files/folders.  We current use 7z.dll to create and extract these files as needed. 

The issue I'm running into when testing with SynZip is an error on a particular archived file which often times is a of zero length in the ZIP.  Winzip and 7Zip (and a few others) have no issue with the archive, but SynZip throws an exception on the file on creation of the TZIPRead object:

TZipRead.Create(BufZip: pByteArray; Size: cardinal);

if infoLocal^.flags and (1 shl 3)=0 then
   if (infoLocal^.zzipSize=0) or (infoLocal^.zfullSize=0) then
      raise ESynZipException.CreateFmt('"%s" size=0 in ZIP',[zipName]);

As a test I simply comment out the exception and the rest of my test works fine (although my current test is doing nothing with that particular file in the archive):
if infoLocal^.flags and (1 shl 3)=0 then
    if (infoLocal^.zzipSize=0) or (infoLocal^.zfullSize=0) then
    begin
          //raise ESynZipException.CreateFmt('"%s" size=0 in ZIP',[zipName]);
    end;

But, you obviously raise this exception for some reason and so I would like to understand the proper way to move forward with SynZip in this case.  Any help in resolving this so that i can continue my testing will be greatly appreciated.

Offline

#2 2015-11-11 09:25:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Re: SynZip with Zero Length Files

Offline

#3 2015-11-24 18:06:00

ehansen
Member
Registered: 2015-11-10
Posts: 2

Re: SynZip with Zero Length Files

That was really fast, thanks!   I had noticed and re-tested with you're update back around 11/14, your changes worked perfectly. I had also replied with info for others based on my testing, but maybe I never hit send (?), so I'm doing it again as best I can without having all of my test data.

My work in this case was really to determine the feasibility of replacing 7z.dll with Synzip more so than any actual speed testing, but I did some speed testing while I was at it to get an idea of how the two compared.  The test involved rather small zip files (around 150kb) with each archive containing 120-150 files.  The application opens each archive, searches for one particular file, and then extracts that file if it is found.  This was done for around 30 archives and I repeated the entire test 5 times with Synzip and 5 times with 7z.Dll.  The original code using 7z.Dll averaged about 0.52 seconds to complete all the work, SynZip version took 0.05 seconds.  The extracted files were identical, as expected.

With such small archives I expected little difference in speed, so the results were pretty surprising, with SynZip being the clear winner!  Thanks again to Synopse for what is seeming to be a great open source library.  I'll try to remember to post other results as I continue to evaluate the code base.

Offline

#4 2020-04-15 12:22:08

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: SynZip with Zero Length Files

A small fix for gzip package what contains a 0 length string - pull #308

Preambula:

I got an issue while sends request to 3-paty service (web server is Apache, app is Cisco web service, so I think this is really Apache behavior):

I send a PUT request with what should returns 200 OK with empty body and Transfer-Encoding: chunked (no Content-Length header)

In case I adds Accept-Encoding: gzip; header service returns empty gzip in body. The response content is

(master)$ xxd r.bin 
00000000: 1f8b 0800 0000 0000 0003 0000 00ff ff03  ................
00000010: 0000 0000 0000 0000 00                   .........

At last from curl POW this is valid gzip with 0 length but SynZip fails on such ZIP package. This patch fix it

Offline

Board footer

Powered by FluxBB