Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null password on ReaderFactory. Fix null options on SevenZipArchive #188

Merged
merged 2 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static SevenZipArchive Open(string filePath, ReaderOptions readerOptions
/// </summary>
/// <param name="fileInfo"></param>
/// <param name="readerOptions"></param>
public static SevenZipArchive Open(FileInfo fileInfo, ReaderOptions readerOptions)
public static SevenZipArchive Open(FileInfo fileInfo, ReaderOptions readerOptions = null)
{
fileInfo.CheckNotNull("fileInfo");
return new SevenZipArchive(fileInfo, readerOptions ?? new ReaderOptions());
Expand All @@ -44,7 +44,7 @@ public static SevenZipArchive Open(FileInfo fileInfo, ReaderOptions readerOption
public static SevenZipArchive Open(Stream stream, ReaderOptions readerOptions = null)
{
stream.CheckNotNull("stream");
return new SevenZipArchive(stream, readerOptions);
return new SevenZipArchive(stream, readerOptions ?? new ReaderOptions());
}

#if !NO_FILE
Expand Down
4 changes: 2 additions & 2 deletions src/SharpCompress/Common/Volume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public abstract class Volume : IVolume
{
private readonly Stream actualStream;

internal Volume(Stream stream, ReaderOptions readerFactoryOptions)
internal Volume(Stream stream, ReaderOptions readerOptions)
{
actualStream = stream;
ReaderOptions = readerFactoryOptions;
ReaderOptions = readerOptions;
}

internal Stream Stream { get { return new NonDisposingStream(actualStream); } }
Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/Readers/AbstractReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal AbstractReader(ReaderOptions options, ArchiveType archiveType)
Options = options;
}

internal ReaderOptions Options { get; private set; }
internal ReaderOptions Options { get; }

public ArchiveType ArchiveType { get; }

Expand Down
2 changes: 1 addition & 1 deletion src/SharpCompress/Readers/ReaderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static IReader Open(Stream stream, ReaderOptions options = null)
};
RewindableStream rewindableStream = new RewindableStream(stream);
rewindableStream.StartRecording();
if (ZipArchive.IsZipFile(rewindableStream, null))
if (ZipArchive.IsZipFile(rewindableStream, options.Password))
{
rewindableStream.Rewind(true);
return ZipReader.Open(rewindableStream, options);
Expand Down
4 changes: 4 additions & 0 deletions test/SharpCompress.Test/Zip/ZipReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public override bool CanSeek
[Fact]
public void TestSharpCompressWithEmptyStream()
{
ResetScratch();

MemoryStream stream = new NonSeekableMemoryStream();

using (IWriter zipWriter = WriterFactory.Open(stream, ArchiveType.Zip, CompressionType.Deflate))
Expand All @@ -250,7 +252,9 @@ public void TestSharpCompressWithEmptyStream()
byte[] buf = new byte[bufSize];
int bytesRead = 0;
while ((bytesRead = entry.Read(buf, 0, bufSize)) > 0)
{
tempStream.Write(buf, 0, bytesRead);
}
}
}
}
Expand Down