Exemplo n.º 1
0
        public PackageQueryService(IPackageCacheService packageCacheService, IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => packageCacheService);
            Argument.IsNotNull(() => repositoryCacheService);

            _packageCacheService    = packageCacheService;
            _repositoryCacheService = repositoryCacheService;
        }
        public PackageQueryService(IPackageCacheService packageCacheService, IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => packageCacheService);
            Argument.IsNotNull(() => repositoryCacheService);

            _packageCacheService = packageCacheService;
            _repositoryCacheService = repositoryCacheService;
        }
        public PackagesUpdatesSearcherService(IRepositoryService repositoryService, IPackageCacheService packageCacheService,
                                              IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => repositoryCacheService);

            _repositoryService      = repositoryService;
            _packageCacheService    = packageCacheService;
            _repositoryCacheService = repositoryCacheService;
        }
        public PackagesUpdatesSearcherService(IRepositoryService repositoryService, IPackageCacheService packageCacheService,
            IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => repositoryCacheService);

            _repositoryService = repositoryService;
            _packageCacheService = packageCacheService;
            _repositoryCacheService = repositoryCacheService;
        }
Exemplo n.º 5
0
        public PackageManager(IRepositoryService repositoryService, INuGetConfigurationService nuGetConfigurationService,
            ILogger logger, IPackageCacheService packageCacheService, IRepositoryCacheService repositoryCacheService)
            : this(repositoryService.GetSourceAggregateRepository(), repositoryCacheService, nuGetConfigurationService.GetDestinationFolder())
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => nuGetConfigurationService);
            Argument.IsNotNull(() => logger);
            Argument.IsNotNull(() => packageCacheService);

            _packageCacheService = packageCacheService;
            Logger = logger;
        }
Exemplo n.º 6
0
        public PackageManager(IRepositoryService repositoryService, INuGetConfigurationService nuGetConfigurationService,
                              ILogger logger, IPackageCacheService packageCacheService, IRepositoryCacheService repositoryCacheService)
            : this(repositoryService.GetSourceAggregateRepository(), repositoryCacheService, nuGetConfigurationService.GetDestinationFolder())
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => nuGetConfigurationService);
            Argument.IsNotNull(() => logger);
            Argument.IsNotNull(() => packageCacheService);

            _packageCacheService = packageCacheService;
            Logger = logger;
        }
        public PackagesUpdatesSearcherService(IRepositoryService repositoryService, IAuthenticationSilencerService authenticationSilencerService, IPackageCacheService packageCacheService,
            IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => authenticationSilencerService);
            Argument.IsNotNull(() => repositoryCacheService);

            _repositoryService = repositoryService;
            _authenticationSilencerService = authenticationSilencerService;
            _packageCacheService = packageCacheService;
            _repositoryCacheService = repositoryCacheService;
        }
Exemplo n.º 8
0
        public PackagesUpdatesSearcherService(IRepositoryService repositoryService, IAuthenticationSilencerService authenticationSilencerService, IPackageCacheService packageCacheService,
                                              IRepositoryCacheService repositoryCacheService)
        {
            Argument.IsNotNull(() => repositoryService);
            Argument.IsNotNull(() => authenticationSilencerService);
            Argument.IsNotNull(() => repositoryCacheService);

            _repositoryService             = repositoryService;
            _authenticationSilencerService = authenticationSilencerService;
            _packageCacheService           = packageCacheService;
            _repositoryCacheService        = repositoryCacheService;
        }
Exemplo n.º 9
0
 public MirrorService(
     INuGetClient client,
     IPackageCacheService localPackages,
     IPackageDownloader downloader,
     ILogger <MirrorService> logger,
     MirrorOptions options)
 {
     _startLock          = new object();
     _downloads          = new Dictionary <PackageIdentity, Task>();
     _localPackages      = localPackages ?? throw new ArgumentNullException(nameof(localPackages));
     _downloader         = downloader ?? throw new ArgumentNullException(nameof(downloader));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     this._loggerAdapter = new NuGetLoggerAdapter <MirrorService>(_logger);
     _sourceRepository   = client.GetRepository(options.UpstreamIndex);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Look for the INupkg instance in the cache first. If it's in the cache, return it.
        /// Otherwise, download the package from the storage service and store it into the cache.
        /// </summary>
        public static async Task<INupkg> GetPackageFromCacheOrDownloadIt(
            Package package,
            IPackageCacheService cacheService,
            IPackageFileService packageFileService)
        {
            Debug.Assert(package != null);
            Debug.Assert(cacheService != null);
            Debug.Assert(packageFileService != null);

            string cacheKey = CreateCacheKey(package.PackageRegistration.Id, package.Version);
            byte[] buffer = cacheService.GetBytes(cacheKey);
            if (buffer == null)
            {
                // In the past, some very old packages can specify an external package binary not hosted at nuget.org.
                // We no longer allow that today.
                if (!String.IsNullOrEmpty(package.ExternalPackageUrl))
                {
                    var httpClient = new HttpClient();
                    using (var responseStream = await httpClient.GetStreamAsync(package.ExternalPackageUrl))
                    {
                        buffer = responseStream.ReadAllBytes();
                    }
                }
                else
                {
                    using (Stream stream = await packageFileService.DownloadPackageFileAsync(package))
                    {
                        if (stream == null)
                        {
                            throw new InvalidOperationException("Couldn't download the package from the storage.");
                        }

                        buffer = stream.ReadAllBytes();
                    }
                }

                cacheService.SetBytes(cacheKey, buffer);
            }

            return new Nupkg(new MemoryStream(buffer), leaveOpen: false);
        }