Skip to content

Commit

Permalink
Address feedback (#343)
Browse files Browse the repository at this point in the history
Addresses #341
  • Loading branch information
loic-sharma committed Sep 18, 2019
1 parent 059662e commit 241512a
Show file tree
Hide file tree
Showing 119 changed files with 763 additions and 686 deletions.
2 changes: 1 addition & 1 deletion src/BaGet.Aws/Configuration/S3StorageOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using BaGet.Core.Validation;
using BaGet.Core;

namespace BaGet.Aws.Configuration
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Aws/S3StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Amazon.S3;
using Amazon.S3.Model;
using BaGet.Aws.Configuration;
using BaGet.Core.Storage;
using BaGet.Core;
using Microsoft.Extensions.Options;

namespace BaGet.Aws
Expand Down
3 changes: 1 addition & 2 deletions src/BaGet.Azure/BlobStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Extensions;
using BaGet.Core.Storage;
using BaGet.Core;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

Expand Down
5 changes: 3 additions & 2 deletions src/BaGet.Azure/Configuration/AzureSearchOptions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using BaGet.Core;

namespace BaGet.Azure.Configuration
{
public class AzureSearchOptions : Core.Configuration.SearchOptions
public class AzureSearchOptions : SearchOptions
{
[Required]
public string AccountName { get; set; }
Expand Down
5 changes: 1 addition & 4 deletions src/BaGet.Azure/Search/AzureSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core;
using BaGet.Core.Entities;
using BaGet.Core.Indexing;
using BaGet.Core.Search;
using BaGet.Protocol.Models;
using Microsoft.Azure.Search;
using NuGet.Versioning;
Expand All @@ -17,7 +14,7 @@ namespace BaGet.Azure.Search
using QueryType = Microsoft.Azure.Search.Models.QueryType;
using SearchParameters = Microsoft.Azure.Search.Models.SearchParameters;

public class AzureSearchService : IBaGetSearchResource
public class AzureSearchService : ISearchService
{
private readonly BatchIndexer _indexer;
private readonly SearchIndexClient _searchClient;
Expand Down
3 changes: 1 addition & 2 deletions src/BaGet.Azure/Search/BatchIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BaGet.Core.Entities;
using BaGet.Core.Metadata;
using BaGet.Core;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Microsoft.Extensions.Logging;
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Core.Server/Controllers/PackageContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace BaGet.Controllers
/// </summary>
public class PackageContentController : Controller
{
private readonly IBaGetPackageContentService _content;
private readonly IPackageContentService _content;

public PackageContentController(IBaGetPackageContentService content)
public PackageContentController(IPackageContentService content)
{
_content = content ?? throw new ArgumentNullException(nameof(content));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Metadata;
using BaGet.Core;
using BaGet.Protocol.Models;
using Microsoft.AspNetCore.Mvc;
using NuGet.Versioning;
Expand All @@ -14,9 +14,9 @@ namespace BaGet.Controllers
/// </summary>
public class PackageMetadataController : Controller
{
private readonly IBaGetPackageMetadataService _metadata;
private readonly IPackageMetadataService _metadata;

public PackageMetadataController(IBaGetPackageMetadataService metadata)
public PackageMetadataController(IPackageMetadataService metadata)
{
_metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Authentication;
using BaGet.Core.Configuration;
using BaGet.Core.Indexing;
using BaGet.Core.Metadata;
using BaGet.Core;
using BaGet.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down
6 changes: 3 additions & 3 deletions src/BaGet.Core.Server/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Search;
using BaGet.Core;
using BaGet.Protocol.Models;
using Microsoft.AspNetCore.Mvc;

namespace BaGet.Controllers
{
public class SearchController : Controller
{
private readonly IBaGetSearchResource _searchService;
private readonly ISearchService _searchService;

public SearchController(IBaGetSearchResource searchService)
public SearchController(ISearchService searchService)
{
_searchService = searchService ?? throw new ArgumentNullException(nameof(searchService));
}
Expand Down
6 changes: 3 additions & 3 deletions src/BaGet.Core.Server/Controllers/ServiceIndexController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.ServiceIndex;
using BaGet.Core;
using BaGet.Protocol.Models;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -12,9 +12,9 @@ namespace BaGet.Controllers
/// </summary>
public class ServiceIndexController : Controller
{
private readonly IBaGetServiceIndex _serviceIndex;
private readonly IServiceIndexService _serviceIndex;

public ServiceIndexController(IBaGetServiceIndex serviceIndex)
public ServiceIndexController(IServiceIndexService serviceIndex)
{
_serviceIndex = serviceIndex ?? throw new ArgumentNullException(nameof(serviceIndex));
}
Expand Down
5 changes: 1 addition & 4 deletions src/BaGet.Core.Server/Controllers/SymbolController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Authentication;
using BaGet.Core.Configuration;
using BaGet.Core.Indexing;
using BaGet.Core.Storage;
using BaGet.Core;
using BaGet.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Core.Server/Extensions/HttpRequestExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Extensions;
using BaGet.Core;
using Microsoft.AspNetCore.Http;

namespace BaGet.Extensions
Expand Down
3 changes: 1 addition & 2 deletions src/BaGet.Core/Authentication/ApiKeyAuthenticationService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Threading.Tasks;
using BaGet.Core.Configuration;
using Microsoft.Extensions.Options;

namespace BaGet.Core.Authentication
namespace BaGet.Core
{
public class ApiKeyAuthenticationService : IAuthenticationService
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Authentication/IAuthenticationService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace BaGet.Core.Authentication
namespace BaGet.Core
{
public interface IAuthenticationService
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/BaGetOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;

namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class BaGetOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/DatabaseOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;

namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class DatabaseOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/FileSystemStorageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Linq;

namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class FileSystemStorageOptions : StorageOptions, IValidatableObject
{
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Core/Configuration/MirrorOptions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class MirrorOptions : IValidatableObject
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/PackageDeletionBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BaGet.Core.Configuration
namespace BaGet.Core
{
/// <summary>
/// How BaGet should interpret package deletion requests.
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/SearchOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class SearchOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Core/Configuration/StorageOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BaGet.Core.Configuration
namespace BaGet.Core
{
public class StorageOptions
{
Expand Down
15 changes: 8 additions & 7 deletions src/BaGet.Core/Content/DatabasePackageContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Core.Metadata;
using BaGet.Core.Mirror;
using BaGet.Core.Storage;
using BaGet.Protocol;
using BaGet.Protocol.Models;
using NuGet.Versioning;

Expand All @@ -17,20 +13,25 @@ namespace BaGet.Core.Content
/// Tracks state in a database (<see cref="IPackageService"/>) and stores packages
/// using <see cref="IPackageStorageService"/>.
/// </summary>
public class DatabasePackageContentService : IBaGetPackageContentService
public class DatabasePackageContentService : IPackageContentService
{
private readonly IMirrorService _mirror;
private readonly IPackageService _packages;
private readonly IPackageStorageService _storage;

public DatabasePackageContentService(IMirrorService mirror, IPackageService packages, IPackageStorageService storage)
public DatabasePackageContentService(
IMirrorService mirror,
IPackageService packages,
IPackageStorageService storage)
{
_mirror = mirror ?? throw new ArgumentNullException(nameof(mirror));
_packages = packages ?? throw new ArgumentNullException(nameof(packages));
_storage = storage ?? throw new ArgumentNullException(nameof(storage));
}

public async Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(string id, CancellationToken cancellationToken = default)
public async Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(
string id,
CancellationToken cancellationToken = default)
{
// First, attempt to find all package versions using the upstream source.
var versions = await _mirror.FindPackageVersionsOrNullAsync(id, cancellationToken);
Expand Down
26 changes: 0 additions & 26 deletions src/BaGet.Core/Content/IBaGetPackageContentService.cs

This file was deleted.

71 changes: 71 additions & 0 deletions src/BaGet.Core/Content/IPackageContentService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using BaGet.Protocol.Models;
using NuGet.Versioning;

namespace BaGet.Core.Content
{
/// <summary>
/// The Package Content resource, used to download NuGet packages and to fetch other metadata.
///
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource
/// </summary>
public interface IPackageContentService
{
/// <summary>
/// Get a package's versions, or null if the package does not exist.
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions
/// </summary>
/// <param name="packageId">The package ID.</param>
/// <param name="cancellationToken">A token to cancel the task.</param>
/// <returns>The package's versions, or null if the package does not exist.</returns>
Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync(
string packageId,
CancellationToken cancellationToken = default);

/// <summary>
/// Download a package, or null if the package does not exist.
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg
/// </summary>
/// <param name="packageId">The package ID.</param>
/// <param name="packageVersion">The package's version.</param>
/// <param name="cancellationToken">A token to cancel the task.</param>
/// <returns>
/// The package's content stream, or null if the package does not exist. The stream may not be seekable.
/// </returns>
Task<Stream> GetPackageContentStreamOrNullAsync(
string packageId,
NuGetVersion packageVersion,
CancellationToken cancellationToken = default);

/// <summary>
/// Download a package's manifest (nuspec), or null if the package does not exist.
/// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec
/// </summary>
/// <param name="packageId">The package id.</param>
/// <param name="packageVersion">The package's version.</param>
/// <param name="cancellationToken">A token to cancel the task.</param>
/// <returns>
/// The package's manifest stream, or null if the package does not exist. The stream may not be seekable.
/// </returns>
Task<Stream> GetPackageManifestStreamOrNullAsync(
string packageId,
NuGetVersion packageVersion,
CancellationToken cancellationToken = default);

/// <summary>
/// Download a package's readme, or null if the package or readme does not exist.
/// </summary>
/// <param name="id">The package id.</param>
/// <param name="version">The package's version.</param>
/// <param name="cancellationToken">A token to cancel the task.</param>
/// <returns>
/// The package's readme stream, or null if the package or readme does not exist. The stream may not be seekable.
/// </returns>
Task<Stream> GetPackageReadmeStreamOrNullAsync(
string id,
NuGetVersion version,
CancellationToken cancellationToken = default);
}
}
2 changes: 1 addition & 1 deletion src/BaGet.Core/Entities/AbstractContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace BaGet.Core.Entities
namespace BaGet.Core
{
public abstract class AbstractContext<TContext> : DbContext, IContext where TContext : DbContext
{
Expand Down

0 comments on commit 241512a

Please sign in to comment.