Skip to content

Commit 3e5a968

Browse files
authored
Merge pull request #6802 from NuGet/dev
[ReleasePrep][2018.01.07]RI of dev into master
2 parents 9957095 + 8b9d58a commit 3e5a968

32 files changed

+465
-70
lines changed

src/NuGetGallery.Core/Services/AccessConditionWrapper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public static IAccessCondition GenerateIfMatchCondition(string etag)
3131
ifMatchETag: AccessCondition.GenerateIfMatchCondition(etag).IfMatchETag);
3232
}
3333

34+
public static IAccessCondition GenerateIfNoneMatchCondition(string etag)
35+
{
36+
return new AccessConditionWrapper(
37+
ifNoneMatchETag: AccessCondition.GenerateIfNoneMatchCondition(etag).IfNoneMatchETag,
38+
ifMatchETag: null);
39+
}
40+
3441
public static IAccessCondition GenerateIfNotExistsCondition()
3542
{
3643
return new AccessConditionWrapper(

src/NuGetGallery.Core/Services/CloudBlobWrapper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public CloudBlobWrapper(CloudBlockBlob blob)
2929
_blob = blob;
3030
}
3131

32+
public async Task<Stream> OpenReadAsync(AccessCondition accessCondition)
33+
{
34+
return await _blob.OpenReadAsync(
35+
accessCondition: accessCondition,
36+
options: null,
37+
operationContext: null);
38+
}
39+
3240
public async Task DeleteIfExistsAsync()
3341
{
3442
await _blob.DeleteIfExistsAsync(

src/NuGetGallery.Core/Services/CoreLicenseFileService.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,7 @@ public Task SaveLicenseFileAsync(Package package, Stream licenseFile)
4242

4343
var fileName = BuildLicenseFileName(package);
4444

45-
// Gallery will generally ignore the content type on license files and will use the value from the DB,
46-
// but we'll be nice and try to specify correct content type for them.
47-
var contentType = package.EmbeddedLicenseType == EmbeddedLicenseFileType.Markdown
48-
? CoreConstants.MarkdownContentType
49-
: CoreConstants.TextContentType;
50-
51-
return _fileStorageService.SaveFileAsync(_metadata.PackageContentFolderName, fileName, contentType, licenseFile, overwrite: true);
45+
return _fileStorageService.SaveFileAsync(_metadata.PackageContentFolderName, fileName, CoreConstants.TextContentType, licenseFile, overwrite: true);
5246
}
5347

5448
public async Task ExtractAndSaveLicenseFileAsync(Package package, Stream packageStream)

src/NuGetGallery.Core/Services/ISimpleCloudBlob.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public interface ISimpleCloudBlob
2020
DateTime LastModifiedUtc { get; }
2121
string ETag { get; }
2222

23+
Task<Stream> OpenReadAsync(AccessCondition accessCondition);
24+
2325
Task DeleteIfExistsAsync();
2426
Task DownloadToStreamAsync(Stream target);
2527
Task DownloadToStreamAsync(Stream target, AccessCondition accessCondition);

src/NuGetGallery/Areas/Admin/Services/ISupportRequestService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Task<Issue> AddNewSupportRequestAsync(
5757

5858
Task AddAdminAsync(string galleryUsername);
5959

60-
Task DeleteSupportRequestsAsync(string createdBy);
60+
Task DeleteSupportRequestsAsync(User user);
6161

6262
Task<bool> TryAddDeleteSupportRequestAsync(User user);
6363
}

src/NuGetGallery/Areas/Admin/Services/SupportRequestService.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,27 @@ public string GetIssueStatusNameById(int id)
286286
return issue?.Name;
287287
}
288288

289-
public async Task DeleteSupportRequestsAsync(string createdBy)
289+
public async Task DeleteSupportRequestsAsync(User user)
290290
{
291-
if (createdBy == null)
291+
if (user == null)
292292
{
293-
throw new ArgumentNullException(nameof(createdBy));
293+
throw new ArgumentNullException(nameof(user));
294294
}
295-
var userCreatedIssues = GetIssues().Where(i => string.Equals(i.CreatedBy, createdBy, StringComparison.InvariantCultureIgnoreCase)).ToList();
295+
var userIssues = GetIssues().Where(i => i.UserKey.HasValue && i.UserKey.Value == user.Key).ToList();
296296
// Delete all the support requests with exception of the delete account request.
297297
// For the DeleteAccount support request clean the user data.
298-
foreach (var issue in userCreatedIssues.Where(i => !string.Equals(i.IssueTitle, Strings.AccountDelete_SupportRequestTitle)))
298+
foreach (var issue in userIssues.Where(i => !string.Equals(i.IssueTitle, Strings.AccountDelete_SupportRequestTitle)))
299299
{
300300
_supportRequestDbContext.Issues.Remove(issue);
301301
}
302-
foreach (var accountDeletedIssue in userCreatedIssues.Where(i => string.Equals(i.IssueTitle, Strings.AccountDelete_SupportRequestTitle)))
302+
foreach (var accountDeletedIssue in userIssues.Where(i => string.Equals(i.IssueTitle, Strings.AccountDelete_SupportRequestTitle)))
303303
{
304304
accountDeletedIssue.OwnerEmail = "deletedaccount";
305305
accountDeletedIssue.CreatedBy = null;
306+
accountDeletedIssue.Details = "This support request has been redacted as the customer's account has been deleted.";
306307
foreach (var historyEntry in accountDeletedIssue.HistoryEntries)
307308
{
308-
if (string.Equals(historyEntry.EditedBy, createdBy, StringComparison.InvariantCultureIgnoreCase))
309+
if (string.Equals(historyEntry.EditedBy, user.Username, StringComparison.InvariantCultureIgnoreCase))
309310
{
310311
historyEntry.EditedBy = null;
311312
}

src/NuGetGallery/GalleryConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class GalleryConstants
1717
public const int ColumnsAuthenticationMd = 4;
1818
public const int ColumnsWideAuthenticationSm = 8;
1919
public const int ColumnsWideAuthenticationMd = 6;
20-
public const int ColumnsFormMd = 10;
20+
public const int ColumnsFormMd = 12;
2121

2222
public const int VisibleVersions = 5;
2323

src/NuGetGallery/Services/DeleteAccountService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private async Task RemoveUserDataInUserTable(User user)
282282

283283
private async Task RemoveSupportRequests(User user)
284284
{
285-
await _supportRequestService.DeleteSupportRequestsAsync(user.Username);
285+
await _supportRequestService.DeleteSupportRequestsAsync(user);
286286
}
287287

288288
private async Task RemoveUser(User user)

src/NuGetGallery/Services/PackageService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public async Task EnsureValid(PackageArchiveReader packageArchiveReader)
5656
packageArchiveReader.GetNuspecReader(),
5757
strict: true);
5858

59+
if (packageMetadata.IsSymbolsPackage())
60+
{
61+
throw new InvalidPackageException(Strings.UploadPackage_SymbolsPackageNotAllowed);
62+
}
63+
5964
PackageHelper.ValidateNuGetPackageMetadata(packageMetadata);
6065

6166
var supportedFrameworks = GetSupportedFrameworks(packageArchiveReader).Select(fn => fn.ToShortNameOrNull()).ToArray();

src/NuGetGallery/Services/ReservedNamespaceService.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace NuGetGallery
1515
{
1616
public class ReservedNamespaceService : IReservedNamespaceService
1717
{
18-
private static readonly Regex NamespaceRegex = new Regex(@"^\w+([_.-]\w+)*[.]?$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
18+
private static readonly Regex NamespaceRegex = new Regex(@"^\w+([_.-]\w+)*[.-]?$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
1919

2020
public IEntitiesContext EntitiesContext { get; protected set; }
2121
public IEntityRepository<ReservedNamespace> ReservedNamespaceRepository { get; protected set; }
@@ -47,7 +47,14 @@ public async Task AddReservedNamespaceAsync(ReservedNamespace newNamespace)
4747
throw new ArgumentNullException(nameof(newNamespace));
4848
}
4949

50-
ValidateNamespace(newNamespace.Value);
50+
try
51+
{
52+
ValidateNamespace(newNamespace.Value);
53+
}
54+
catch (ArgumentException ex)
55+
{
56+
throw new InvalidOperationException(ex.Message, ex);
57+
}
5158

5259
var matchingReservedNamespaces = FindAllReservedNamespacesForPrefix(prefix: newNamespace.Value, getExactMatches: !newNamespace.IsPrefix);
5360
if (matchingReservedNamespaces.Any())
@@ -348,12 +355,12 @@ public static void ValidateNamespace(string value)
348355
throw new ArgumentException(Strings.ReservedNamespace_InvalidNamespace);
349356
}
350357

351-
if (value.Length > NuGet.Services.Entities.Constants.MaxPackageIdLength)
358+
if (value.Length > Constants.MaxPackageIdLength)
352359
{
353360
throw new ArgumentException(string.Format(
354361
CultureInfo.CurrentCulture,
355362
Strings.ReservedNamespace_NamespaceExceedsLength,
356-
NuGet.Services.Entities.Constants.MaxPackageIdLength));
363+
Constants.MaxPackageIdLength));
357364
}
358365

359366
if (!NamespaceRegex.IsMatch(value))

0 commit comments

Comments
 (0)