Skip to content

Commit

Permalink
Fix #1745 by showing error if minClientVersion > current NuGet version
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Nov 25, 2013
1 parent 4f3ffb9 commit 89b420e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/NuGetGallery/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ private async Task<ActionResult> CreatePackageInternal()

using (var packageToPush = ReadPackageFromRequest())
{
if (packageToPush.Metadata.MinClientVersion > typeof(Manifest).Assembly.GetName().Version)
{
return new HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest, String.Format(
CultureInfo.CurrentCulture,
Strings.UploadPackage_MinClientVersionOutOfRange,
packageToPush.Metadata.MinClientVersion));
}

// Ensure that the user can push packages for this partialId.
var packageRegistration = PackageService.FindPackageRegistrationById(packageToPush.Metadata.Id);
if (packageRegistration != null)
Expand Down
12 changes: 12 additions & 0 deletions src/NuGetGallery/Controllers/PackagesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public virtual async Task<ActionResult> UploadPackage(HttpPostedFileBase uploadF
return View();
}

// Check min client version
if (nuGetPackage.Metadata.MinClientVersion > typeof(Manifest).Assembly.GetName().Version)
{
ModelState.AddModelError(
String.Empty,
String.Format(
CultureInfo.CurrentCulture,
Strings.UploadPackage_MinClientVersionOutOfRange,
nuGetPackage.Metadata.MinClientVersion));
return View();
}

var packageRegistration = _packageService.FindPackageRegistrationById(nuGetPackage.Metadata.Id);
if (packageRegistration != null && !packageRegistration.Owners.AnySafe(x => x.Key == currentUser.Key))
{
Expand Down
9 changes: 9 additions & 0 deletions src/NuGetGallery/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/NuGetGallery/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,7 @@ The {2} Team</value>
<data name="EmailUpdated_ConfirmationRequired" xml:space="preserve">
<value>Your email address has been changed! We sent a confirmation email to verify your new email. When you confirm the new email address, it will take effect and we will forget the old one.</value>
</data>
<data name="UploadPackage_MinClientVersionOutOfRange" xml:space="preserve">
<value>This package requires version '{0}' of NuGet, which this gallery does not currently support. Please contact us if you have questions.</value>
</data>
</root>

0 comments on commit 89b420e

Please sign in to comment.