#1 2022-07-28 00:35:29

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

SynZip created file, 7Zip report header errors

Hi Arnaud

I'm not able to find what can be the cause of this, let me explain:

I am creating at runtime a lot of XML Documents ( TXMLDocument ) which I must add to a ZIP file to send them over the network to a third party, this was an existing project which was already creating the XML  and using the SaveToFile method to store them on disk, then, to create the compressed file(s) I used TZipWrite to add the xml files using the AddDeflated method like this:

ZIPFile.AddDeflated('test.xml');

This works and the created files are ok, but, because there are more than 20,000 xml files, do it this way is slow, so instead of saving the XML to disk, at runtime I am storing the XML.Text property of each generated documento on a RawByteString variable (strXML):

strXML := xmlObj.XML.Text

and then doing:

ZIPFile.AddDeflated('test.xml', pointer(strXML), length(strXML) );

Using this method the process is much faster and I can open the final zip, see the files, uncompress them, but the software of the third party which process this ZIP files refuses to process them, he tells me they are corrupt and as a proof he asked me to extract them with 7zip and indeed 7zip says: Headers Error

I did a test with just one XML, adding it from a saved XML on disk, and opening the ZIP file in 7Zip I can se this in File - Properties

Size: 3 745
Packed Size: 2 106
Folders: 0
Files: 1
CRC: 166FAA28
Type: zip
Physical Size: 2 226

Adding the XML to the zip using the variable, these are the properties of the resulting file on 7Zip

Size: 3 745
Packed Size: 2 106
Folders: 0
Files: 1
CRC: 166FAA28
Warnings: Headers Error
Type: zip
Physical Size: 2 226

I can not see the difference but there is undoubtedly one, how can I add the documents without first saving them to disk and that the headers are correct?

Regards,
Mocte

Offline

#2 2022-07-28 14:38:45

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

Re: SynZip created file, 7Zip report header errors

What about the .zip files created by the mormot2tests.dpr ?

Are they correct in your tests?

Offline

#3 2022-07-28 17:02:59

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: SynZip created file, 7Zip report header errors

I'm not on mormot2, but I've tried the latest SynZip from GitHub, let me download mormot2 and run the tests to confirm.

I'll be right back

Offline

#4 2022-07-28 18:07:24

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: SynZip created file, 7Zip report header errors

Result of testing with mormot2 (mormot.core.zip )

mormot2tests ( write.zip ): no header errors reported
My test with 1 file: no header errors reported
Another test generating 3 zip files with 3000 documents each one: no header errors reported

So no errors whatsoever.

Thank you !  I see you did a nice unit layout in mormot2 and there is no collision name risk, Maybe I'll dare to make the switch

Offline

Board footer

Powered by FluxBB