Skip to content

Commit

Permalink
Merge branch 'tomapGH-5' into dev
Browse files Browse the repository at this point in the history
Fixes tomap#5.
  • Loading branch information
squid-box committed Jul 27, 2018
2 parents 4ca0c3e + a90ac4c commit 7e4df6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
9 changes: 7 additions & 2 deletions SevenZip/ArchiveUpdateCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private void Init(
_fileStream = new InStreamWrapper(stream, false);
_fileStream.BytesRead += IntEventArgsHandler;
_actualFilesCount = 1;

try
{
_bytesCount = stream.Length;
Expand Down Expand Up @@ -411,6 +412,7 @@ public int GetProperty(uint index, ItemPropId propID, ref PropVariant value)

value.VarType = VarEnum.VT_BSTR;
string val = DefaultItemName;

if (_updateData.Mode != InternalCompressionMode.Modify)
{
if (_files == null)
Expand Down Expand Up @@ -759,12 +761,14 @@ public void Dispose()

private void IntEventArgsHandler(object sender, IntEventArgs e)
{
var lockObject = (object) _files ?? _streams;
var lockObject = ((object) _files ?? _streams) ?? _fileStream;

lock (lockObject)
{
var pold = (byte) ((_bytesWrittenOld*100)/_bytesCount);
var pold = (byte) (_bytesWrittenOld*100/_bytesCount);
_bytesWritten += e.Value;
byte pnow;

if (_bytesCount < _bytesWritten) //Holy shit, this check for ZIP is golden
{
pnow = 100;
Expand All @@ -773,6 +777,7 @@ private void IntEventArgsHandler(object sender, IntEventArgs e)
{
pnow = (byte)((_bytesWritten * 100) / _bytesCount);
}

if (pnow > pold)
{
_bytesWrittenOld = _bytesWritten;
Expand Down
2 changes: 1 addition & 1 deletion SevenZip/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ internal void CheckedExecute(int hresult, string message, CallbackBase handler)
{
ThrowException(handler,
new SevenZipException(
"The execution has failed due to the bug in the SevenZipSharp.\n" +
"Execution has failed due to an internal SevenZipSharp issue.\n" +
"Please report it to https://github.com/squid-box/SevenZipSharp/issues/, include the release number, 7z version used, and attach the archive."));
}
else
Expand Down
12 changes: 2 additions & 10 deletions SevenZipTests/SevenZipCompressorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,7 @@ public void CompressFromStreamTest()
DirectoryStructure = false
};

try
{
compressor.CompressStream(input, output);
}
catch (SevenZipException)
{
Assert.Warn("Legacy bug, needs investigation.");
return;
}
compressor.CompressStream(input, output);
}

}
Expand All @@ -211,7 +203,7 @@ public void CompressFromStreamTest()
using (var extractor = new SevenZipExtractor(TemporaryFile))
{
Assert.AreEqual(1, extractor.FilesCount);
Assert.AreEqual("zip.zip", extractor.ArchiveFileNames[0]);
Assert.AreEqual(new FileInfo(@"TestData\zip.zip").Length, extractor.ArchiveFileData[0].Size);
}
}

Expand Down

0 comments on commit 7e4df6e

Please sign in to comment.