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]; _entries = new string[streamDict.Count];
streamDict.Keys.CopyTo(_entries, 0); streamDict.Keys.CopyTo(_entries, 0);
_actualFilesCount = streamDict.Count; _actualFilesCount = streamDict.Count;
foreach (Stream str in _streams) //zero 11-oct-2014 - we want sequential streams only. length is unknown.
{ //foreach (Stream str in _streams)
if (str != null) //{
{ // if (str != null)
_bytesCount += str.Length; // {
} // _bytesCount += str.Length;
} // }
//}
CommonInit(compressor, updateData, directoryStructure); CommonInit(compressor, updateData, directoryStructure);
} }
@ -780,25 +781,27 @@ namespace SevenZip
private void IntEventArgsHandler(object sender, IntEventArgs e) private void IntEventArgsHandler(object sender, IntEventArgs e)
{ {
lock (_files) //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
var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount); //lock (_files)
_bytesWritten += e.Value; //{
byte pnow; // var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount);
if (_bytesCount < _bytesWritten) //Holy shit, this check for ZIP is golden // _bytesWritten += e.Value;
{ // byte pnow;
pnow = 100; // if (_bytesCount < _bytesWritten) //Holy shit, this check for ZIP is golden
} // {
else // pnow = 100;
{ // }
pnow = (byte)((_bytesWritten * 100) / _bytesCount); // else
} // {
if (pnow > pold) // pnow = (byte)((_bytesWritten * 100) / _bytesCount);
{ // }
_bytesWrittenOld = _bytesWritten; // if (pnow > pold)
OnCompressing(new ProgressEventArgs(pnow, (byte) (pnow - pold))); // {
} // _bytesWrittenOld = _bytesWritten;
} // OnCompressing(new ProgressEventArgs(pnow, (byte) (pnow - pold)));
// }
//}
} }
} }
#endif #endif

View File

@ -1685,7 +1685,9 @@ Enum.GetName(typeof(ZipEncryptionMethod), ZipEncryptionMethod))
#else #else
foreach (var pair in streamDictionary) 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( if (!ThrowException(null, new ArgumentException(
"The specified stream dictionary contains an invalid stream corresponding to the archive entry \"" + pair.Key + "\".", "The specified stream dictionary contains an invalid stream corresponding to the archive entry \"" + pair.Key + "\".",