Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Fix extract from stream #103

Closed

Conversation

misthophoroi
Copy link

@misthophoroi misthophoroi commented May 20, 2020

Changes:

fix unexpected behavior:
SevenZipExtractor dispose archiveStream when created by public SevenZipExtractor(Stream archiveStream)

fix perfomance degradation at SevenZipBase.GetUniqueID()
under high load Identifiers list's length increases upto 80000 and when new object created all cpu time spended at SevenZipBase.GetUniqueID()

add net462 target - fupported long paths by UNC (\\?\disk:\folder\file)

fixed netstandard2.0 target in test projects

Identifiers.Remove(_uniqueID);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Owner

@squid-box squid-box May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what the use of UniqueID is, while this implementation seems faster, it's also limited to ~4 billion instances where the previous implementation was not

Can you shed some light on this?

@@ -107,7 +107,7 @@ private void Init(Stream stream)
SevenZipLibraryManager.LoadLibrary(this, _format);
try
{
_inStream = new ArchiveEmulationStreamProxy(stream, _offset);
_inStream = new ArchiveEmulationStreamProxy(stream, _offset, false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make the last parameter optional (dispose = false) to make the API backward compatible?

@misthophoroi misthophoroi marked this pull request as ready for review May 21, 2020 12:03
@misthophoroi misthophoroi changed the title Fix exctract from stream Fix extract from stream May 21, 2020
@squid-box
Copy link
Owner

Sorry for the silence, this was quite a big PR and a little hard to follow.

In general I appreciate the effort and it seems mostly fine, but I'll add some questions as review comments.

Copy link
Owner

@squid-box squid-box left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, overall this seems good but some details need attention before I'm comfortable merging this.

The most glaring issue is that you're targeting the master branch - please change to the dev branch :)

@@ -0,0 +1,35 @@
name: .NET Core
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inclusion of a workflows config is a bit surprising. What is the reasoning for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have add it to find out why some of SevenZipCompressorTests.cs tests failed at AppVeyor
but then I fix tests at a5d0dd4. If you do not plan to use github workflow for tests can delete it

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net45;net462</TargetFrameworks>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this target changed from .NET Standard 2.0 to Core 2.1, while the SevenZip project itself remains Standard 2.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is only one way how I can run tests with not net45 and net462 frameworks
I found it at https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard#why-cant-my-tests-target-net-standard

SevenZip.sln Outdated Show resolved Hide resolved
SevenZip/ArchiveExtractCallback.cs Outdated Show resolved Hide resolved
SevenZip/ArchiveExtractCallback.cs Outdated Show resolved Hide resolved
SevenZip/SevenZip.csproj Outdated Show resolved Hide resolved
SevenZip/ArchiveEmulationStreamProxy.cs Show resolved Hide resolved
/// Use SevenZipExtractor(string) to extract from disk, though it is not necessary.</param>
/// <remarks>The archive format is guessed by the signature.</remarks>
public SevenZipExtractor(Stream archiveStream)
public SevenZipExtractor(Stream archiveStream, bool leaveOpen = false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much just a suggestion, but wouldn't it be better to reverse this parameter - bool disposeStream = true?

Since the use of leaveOpen downstream is always if (!leaveOpen) it would make for easier reading of the code, in my opinion at least.
The param comment would then be something like Whether or not to dispose the stream after operation is complete..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have change it after @vasily-kirichenko review to make it more like System.IO.StreamReader

SevenZip/SevenZipBase.cs Outdated Show resolved Hide resolved
Identifiers.Remove(_uniqueID);
}
}

Copy link
Owner

@squid-box squid-box May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what the use of UniqueID is, while this implementation seems faster, it's also limited to ~4 billion instances where the previous implementation was not

Can you shed some light on this?

@misthophoroi misthophoroi changed the base branch from master to dev May 31, 2020 14:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants