sevenzipsharp - remove broken code which was requiring input streams to be seekable so that it could get their length so that it could produce a percent-based progress report

This commit is contained in:
zeromus 2014-10-11 21:26:39 +00:00
parent 200d11df62
commit 0303871ac5
2 changed files with 32 additions and 27 deletions

View File

@ -263,13 +263,14 @@ namespace SevenZip
_entries = new string[streamDict.Count];
streamDict.Keys.CopyTo(_entries, 0);
_actualFilesCount = streamDict.Count;
foreach (Stream str in _streams)
{
if (str != null)
{
_bytesCount += str.Length;
}
}
//zero 11-oct-2014 - we want sequential streams only. length is unknown.
//foreach (Stream str in _streams)
//{
// if (str != null)
// {
// _bytesCount += str.Length;
// }
//}
CommonInit(compressor, updateData, directoryStructure);
}
@ -780,25 +781,27 @@ namespace SevenZip
private void IntEventArgsHandler(object sender, IntEventArgs e)
{
lock (_files)
{
var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount);
_bytesWritten += e.Value;
byte pnow;
if (_bytesCount < _bytesWritten) //Holy shit, this check for ZIP is golden
{
pnow = 100;
}
else
{
pnow = (byte)((_bytesWritten * 100) / _bytesCount);
}
if (pnow > pold)
{
_bytesWrittenOld = _bytesWritten;
OnCompressing(new ProgressEventArgs(pnow, (byte) (pnow - pold)));
}
}
//zero 11-oct-2014 - first of all, its possible for _files to be null (if we're compressing streams)
//second of all, if we're compressing streams, we cant possibly have _bytesCount anyway. so.. goodbye
//lock (_files)
//{
// var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount);
// _bytesWritten += e.Value;
// byte pnow;
// if (_bytesCount < _bytesWritten) //Holy shit, this check for ZIP is golden
// {
// pnow = 100;
// }
// else
// {
// pnow = (byte)((_bytesWritten * 100) / _bytesCount);
// }
// if (pnow > pold)
// {
// _bytesWrittenOld = _bytesWritten;
// OnCompressing(new ProgressEventArgs(pnow, (byte) (pnow - pold)));
// }
//}
}
}
#endif

View File

@ -1685,7 +1685,9 @@ Enum.GetName(typeof(ZipEncryptionMethod), ZipEncryptionMethod))
#else
foreach (var pair in streamDictionary)
{
if (pair.Value != null && (!pair.Value.CanSeek || !pair.Value.CanRead))
if (pair.Value != null && (
//!pair.Value.CanSeek || //zero 11-oct-2014 - this is dumb, and I made it no longer necessary
!pair.Value.CanRead))
{
if (!ThrowException(null, new ArgumentException(
"The specified stream dictionary contains an invalid stream corresponding to the archive entry \"" + pair.Key + "\".",