KeyNotFoundException in CompressStream with CompressMode = Append

Jun 30, 2011 at 4:34 PM

Hi

First of all I want to thank the creator for this really great piece of software. :)

We're using 7zipSharp in a "SMTP Proxy" application without problems. We were queuing files to compress and have a background worker process that adds this file to a .7z file, and uploads it via SFTP to a remote server.

Now in order to improve performance and avoid having to save each and every file, we're refactoring this process to use Streams instead of files.

However, the same code using CompressStream fails, after having the first file added.

You can see the source code and tests in this StackOverflow question: http://stackoverflow.com/questions/6537836/appending-streams-with-sevensharpzip

The pseudo-code basically is:

1) Check if outStream == null.

    If it isn't, set CompressionMode = Append (we already have the output stream open).

    If it is, create a new file and set CompressionMode = Create only if the file didn't exist on disk. Otherwise, open the file for writing and set CompressionMode = Append.

2) compressor.CompressStreams(memoryStream, outStream)

3) outStream.Flush()

4) wait for new element in the queue

 

Both streams are valid when the exception is risen. Relevant file is LibraryManager.cs, function InArchive(InArchiveFormat format, object user), line 428. So it seems it is related to extraction.

Any hints?

Thanks,

C