-
Notifications
You must be signed in to change notification settings - Fork 105
SevenZipCompressor Compressing callback returning significantly wrong progress #67
Description
I am not sure if this is an issue with sevenzipsharp or the 7z.dll (I am using one from 7z 19.00), but when I subscribe to the Compressing event, when I inspect the argument's PercentDone value, it seems to be wildly off. It will go from 0-100 very quickly (for a 2GB source directory I am compressing), in which I believe it is filling buffers. After this reaches 100%, I get no more progress notifications until the archive job is complete - which can take several minutes.
When I use 7zip gui to compress this archive, I see correct progress, so I am wondering if maybe the compression callback is binded to the wrong interface to the dll? It shows bytes written going all the way up to the 2GB of data, but it seems more like that's what's read and not what's actually been processed, as my process sits at 14GB of memory for almost 3 minutes until the archive is done being generated.
My code to generate an archive:
var compressor = new SevenZip.SevenZipCompressor();
compressor.CompressionLevel = CompressionLevel.Ultra;
//compressor.CustomParameters.Add("s", "on"); //can't figure out how to make it do solid archives
compressor.Compressing += (a, b) =>
{
Debug.WriteLine(b.PercentDone);
mainWindow.UpdateBusyProgressBarCallback(new ProgressBarUpdate(ProgressBarUpdate.UpdateTypes.SET_VALUE, (int)b.PercentDone));
};
compressor.FileCompressionStarted += (a, b) => { Debug.WriteLine(b.FileName); };
compressor.CompressFileDictionary(archiveMapping, archivePath);
compressor.CompressionMode = CompressionMode.Append;
compressor.CompressionLevel = CompressionLevel.None;
compressor.CompressFiles(archivePath, new string[]
{
Path.Combine(ModBeingDeployed.ModPath, "moddesc.ini")
});
Utilities.HighlightInExplorer(archivePath);
After doing some investigation, it seems the process for archive compression works like this;
- Read source files into memory (this is what the Compressing % callbacks show)
- 7z.dll does it's thing with the file for significant amount of time
- 7z.dll/SevenzipWrapper write the new memory-archive to disk. I can see bytesWritten being raised but it is not being passed back to the sevenzipcompressor it seems (or maybe I missed something).
It is step 2 that would be most useful. I am looking into seeing how it is done in 7z UI, maybe it is exposed via some sort of interface.