Skip to content

Commit

Permalink
Merge pull request #188 from adamhathcock/fix_nulls
Browse files Browse the repository at this point in the history
Fix null password on ReaderFactory.  Fix null options on SevenZipArchive
  • Loading branch information
adamhathcock committed Oct 3, 2016
2 parents c73ac20 + d7e29f7 commit 7efc701
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
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

0 comments on commit 7efc701

Please sign in to comment.