Skip to content

Commit

Permalink
0.0.6 beta2 (#17)
Browse files Browse the repository at this point in the history
* Beta2 bug fix
  • Loading branch information
clarkis117 authored Mar 22, 2018
1 parent 06bc12d commit b147d0c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Mime-Detective/Analyzers/ZipFileAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public FileType Search(in ReadResult readResult)

if (readResult.Source is null)
{
mStream = new MemoryStream(readResult.Array, 0, readResult.ReadLength);
//this should be the length of the array passed via ReadResult
mStream = new MemoryStream(readResult.Array, 0, readResult.Array.Length);
locallyCreatedStream = true;
}
else
Expand Down
9 changes: 9 additions & 0 deletions src/Mime-Detective/Helpers/ReadResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ namespace MimeDetective
/// </summary>
public readonly struct ReadResult : IDisposable
{
/// <summary>
/// Use Array.Length instead of ReadLength when you are refering to the whole file and source is null
/// </summary>
public readonly byte[] Array;

public readonly Stream Source;

/// <summary>
/// This is meant to be the int result of Stream.Read, it should cap at 560
/// Do not use when referring to the whole file
/// </summary>
public readonly int ReadLength;

public bool IsArrayRented { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/Mime-Detective/Mime-Detective.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</PackageTargetFallback>
<AssemblyVersion>0.0.6.0</AssemblyVersion>
<FileVersion>0.0.6.0</FileVersion>
<PackageReleaseNotes>See beta1 PR</PackageReleaseNotes>
<Version>0.0.6.0-beta1</Version>
<PackageReleaseNotes>See beta2 PR</PackageReleaseNotes>
<Version>0.0.6.0-beta2</Version>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions test/Mime-Detective.Tests/Tests/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,14 @@ public async Task StreamIsNotDisposedAfterReadingZipFileTypeAsync()

fileStream.Dispose();
}

[Fact]
public void CanReadZipFileFromByteArray()
{
var result = File.ReadAllBytes("./data/Documents/test.xlsx").GetFileType();

Assert.NotNull(result);
Assert.Equal(MimeTypes.EXCELX, result);
}
}
}

0 comments on commit b147d0c

Please sign in to comment.