Skip to content

Commit

Permalink
Fix for: NuGet/Home#2354
Browse files Browse the repository at this point in the history
  • Loading branch information
simonejsing authored and zhili1208 committed Apr 21, 2016
1 parent 2e9de8e commit 51e2f5d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/NuGet.Core/NuGet.Packaging/PackageFolderReader.cs
Expand Up @@ -104,12 +104,22 @@ public override IEnumerable<string> GetFiles()
{
var searchFolder = new DirectoryInfo(_root.FullName);

foreach (var file in searchFolder.GetFiles("*", SearchOption.AllDirectories).
// Enumerate root folder filtering out nupkg files
foreach (var file in searchFolder.GetFiles("*", SearchOption.TopDirectoryOnly).
Where(p => !p.FullName.EndsWith(PackagingCoreConstants.NupkgExtension, StringComparison.OrdinalIgnoreCase)))
{
yield return GetRelativePath(_root, file);
}

// Enumerate all sub folders without filtering
foreach (var directory in searchFolder.GetDirectories("*", SearchOption.TopDirectoryOnly))
{
foreach (var file in directory.GetFiles("*", SearchOption.AllDirectories))
{
yield return GetRelativePath(_root, file);
}
}

yield break;
}

Expand Down
Expand Up @@ -66,6 +66,39 @@ public void PackageExtractor_DuplicateNupkg()
}
}

[Fact]
public async Task PackageExtractor_NupkgContent()
{
// Arrange
using (var root = TestFileSystemUtility.CreateRandomTestFolder())
{
var packageFileInfo = await TestPackages.GeneratePackageAsync(
root,
"A",
"2.0.4",
DateTimeOffset.UtcNow.LocalDateTime,
"content/A.nupkg");

using (var packageStream = File.OpenRead(packageFileInfo.FullName))
{
var packageExtractionContext = new PackageExtractionContext
{
XmlDocFileSaveMode = XmlDocFileSaveMode.None
};

// Act
var packageFiles = PackageExtractor.ExtractPackage(
packageStream,
new PackagePathResolver(root),
packageExtractionContext,
CancellationToken.None);

// Assert
Assert.True(File.Exists(Path.Combine(root, "A.2.0.4", "content", "A.nupkg")));
}
}
}

[Fact]
public void PackageExtractor_PackageSaveModeNupkg_FolderReader()
{
Expand Down

0 comments on commit 51e2f5d

Please sign in to comment.