Skip to content

Commit

Permalink
Revert "Enable plugin package download" (#1387)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtivel committed Jul 10, 2017
1 parent f4ed99e commit 278e4dd
Show file tree
Hide file tree
Showing 281 changed files with 1,392 additions and 39,234 deletions.
7 changes: 0 additions & 7 deletions NuGet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{96255044
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestUtilities", "TestUtilities", "{79266117-FEDD-45B3-B603-33A4B6E9F12F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestablePlugin", "test\TestExtensions\TestablePlugin\TestablePlugin.csproj", "{F4CA95DA-0045-4AC4-ABA0-560008CEB963}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NuGet.Core.FuncTest", "test\NuGet.Core.FuncTests\NuGet.Core.FuncTest\NuGet.Core.FuncTest.csproj", "{34750BB3-4A21-433A-9C55-C051CA70C4AE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet.Clients", "NuGet.Clients", "{08F523EC-3C2A-4A00-A54C-2E54C5AC856B}"
Expand Down Expand Up @@ -475,10 +473,6 @@ Global
{F813268A-1EA1-41E6-A42C-01E7F937E257}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F813268A-1EA1-41E6-A42C-01E7F937E257}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F813268A-1EA1-41E6-A42C-01E7F937E257}.Release|Any CPU.Build.0 = Release|Any CPU
{F4CA95DA-0045-4AC4-ABA0-560008CEB963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4CA95DA-0045-4AC4-ABA0-560008CEB963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4CA95DA-0045-4AC4-ABA0-560008CEB963}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4CA95DA-0045-4AC4-ABA0-560008CEB963}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -560,6 +554,5 @@ Global
{08F523EC-3C2A-4A00-A54C-2E54C5AC856B} = {BD1946CE-5544-4F28-A04A-9C3D51113E1A}
{506AF844-92E0-4404-BBFC-0AB073890A72} = {BD1946CE-5544-4F28-A04A-9C3D51113E1A}
{F813268A-1EA1-41E6-A42C-01E7F937E257} = {7323F93B-D141-4001-BB9E-7AF14031143E}
{F4CA95DA-0045-4AC4-ABA0-560008CEB963} = {23CEFC88-9365-4464-A517-700224ECA033}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand All @@ -14,7 +14,6 @@
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.ProjectModel;
using NuGet.Protocol;
using NuGet.Repositories;

namespace NuGet.Commands
Expand Down Expand Up @@ -74,41 +73,19 @@ public async Task CopyPackagesToOriginalCaseAsync(IEnumerable<RestoreTargetGraph
}

var originalCaseContext = GetPathContext(identity, isLowercase: _request.IsLowercasePackagesDirectory);
var localPackageFilePath = GetLocalPackageFilePath(remoteMatch);
var packageIdentity = new PackageIdentity(remoteMatch.Library.Name, remoteMatch.Library.Version);
IPackageDownloader packageDependency = null;

if (string.IsNullOrEmpty(localPackageFilePath))
{
packageDependency = await remoteMatch.Provider.GetPackageDownloaderAsync(
packageIdentity,
_request.CacheContext,
_request.Log,
token);
}
else
{
packageDependency = new LocalPackageArchiveDownloader(
localPackageFilePath,
packageIdentity,
_request.Log);
}

// Install the package.
using (packageDependency)
var installed = await PackageExtractor.InstallFromSourceAsync(
destination => CopyToAsync(remoteMatch, destination, token),
originalCaseContext,
token);

if (installed)
{
var installed = await PackageExtractor.InstallFromSourceAsync(
packageDependency,
originalCaseContext,
token);

if (installed)
{
_request.Log.LogMinimal(string.Format(
CultureInfo.CurrentCulture,
Strings.Log_ConvertedPackageToOriginalCase,
identity));
}
_request.Log.LogMinimal(string.Format(
CultureInfo.CurrentCulture,
Strings.Log_ConvertedPackageToOriginalCase,
identity));
}
}
}
Expand Down Expand Up @@ -145,22 +122,39 @@ private static PackageIdentity GetPackageIdentity(RemoteMatch remoteMatch)
remoteMatch.Library.Version);
}

private string GetLocalPackageFilePath(RemoteMatch remoteMatch)
private async Task CopyToAsync(RemoteMatch remoteMatch, Stream destination, CancellationToken token)
{
var library = remoteMatch.Library;

// Try to get the package from the local repositories first.
// Try to get the package from the local repositories first.
var localPackage = NuGetv3LocalRepositoryUtility.GetPackage(
_localRepositories,
library.Name,
library.Version);

if (localPackage != null && File.Exists(localPackage.Package.ZipPath))
{
return localPackage.Package.ZipPath;
using (var stream = new FileStream(
localPackage.Package.ZipPath,
FileMode.Open,
FileAccess.Read,
FileShare.Read,
bufferSize: 4096,
useAsync: true))
{
await stream.CopyToAsync(destination, bufferSize: 4096, cancellationToken: token);
}
}
else
{
// Otherwise, get it from the provider.
await remoteMatch.Provider.CopyToAsync(
remoteMatch.Library,
destination,
_request.CacheContext,
_request.Log,
token);
}

return null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private async Task InstallPackagesAsync(IEnumerable<RestoreTargetGraph> graphs,
}
}

private async Task InstallPackageAsync(RemoteMatch installItem, CancellationToken token)
private Task InstallPackageAsync(RemoteMatch installItem, CancellationToken token)
{
var packageIdentity = new PackageIdentity(installItem.Library.Name, installItem.Library.Version);

Expand All @@ -245,17 +245,15 @@ private async Task InstallPackageAsync(RemoteMatch installItem, CancellationToke
_request.PackageSaveMode,
_request.XmlDocFileSaveMode);

using (var packageDependency = await installItem.Provider.GetPackageDownloaderAsync(
packageIdentity,
_request.CacheContext,
_logger,
token))
{
await PackageExtractor.InstallFromSourceAsync(
packageDependency,
versionFolderPathContext,
token);
}
return PackageExtractor.InstallFromSourceAsync(
stream => installItem.Provider.CopyToAsync(
installItem.Library,
stream,
_request.CacheContext,
_logger,
token),
versionFolderPathContext,
token);
}

private Task<RestoreTargetGraph[]> WalkRuntimeDependenciesAsync(LibraryRange projectRange,
Expand Down
Loading

0 comments on commit 278e4dd

Please sign in to comment.