<commit_before>﻿using System;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace NuGetGallery
{
    public class PackageFileService : IPackageFileService
    {
        private readonly IFileStorageService _fileStorageService;

        public PackageFileService(IFileStorageService fileStorageService)
        {
            _fileStorageService = fileStorageService;
        }

        public Task<ActionResult> CreateDownloadPackageActionResultAsync(Package package)
        {
            var fileName = BuildFileName(package);
            return _fileStorageService.CreateDownloadFileActionResultAsync(Constants.PackagesFolderName, fileName);
        }

        public Task DeletePackageFileAsync(string id, string version)
        {
            if (String.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }

            if (String.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentNullException("version");
            }

            var fileName = BuildFileName(id, version);
            return _fileStorageService.DeleteFileAsync(Constants.PackagesFolderName, fileName);
        }

        public Task SavePackageFileAsync(Package package, Stream packageFile)
        {
            if (packageFile == null)
            {
                throw new ArgumentNullException("packageFile");
            }

            var fileName = BuildFileName(package);
            return _fileStorageService.SaveFileAsync(Constants.PackagesFolderName, fileName, packageFile);
        }

        public Task<Stream> DownloadPackageFile(Package package)
        {
            var fileName = BuildFileName(package);
            return _fileStorageService.GetFileAsync(Constants.PackagesFolderName, fileName);
        }

        public Task<Stream> DownloadPackageFileAsync(Package package)
        {
            var fileName = BuildFileName(package);
            return _fileStorageService.GetFileAsync(Constants.PackagesFolderName, fileName);
        }

        private static string BuildFileName(string id, string version)
        {
            return String.Format(
                CultureInfo.InvariantCulture,
                Constants.PackageFileSavePathTemplate,
                id,
                version,
                Constants.NuGetPackageFileExtension);
        }

        private static string BuildFileName(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            if (package.PackageRegistration == null || 
                String.IsNullOrWhiteSpace(package.PackageRegistration.Id) || 
                String.IsNullOrWhiteSpace(package.Version))
            {
                throw new ArgumentException("The package is missing required data.", "package");
            }

            return BuildFileName(package.PackageRegistration.Id, package.Version);
        }
    }
}<commit_msg>Delete unused method.<commit_after>﻿using System;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace NuGetGallery
{
    public class PackageFileService : IPackageFileService
    {
        private readonly IFileStorageService _fileStorageService;

        public PackageFileService(IFileStorageService fileStorageService)
        {
            _fileStorageService = fileStorageService;
        }

        public Task<ActionResult> CreateDownloadPackageActionResultAsync(Package package)
        {
            var fileName = BuildFileName(package);
            return _fileStorageService.CreateDownloadFileActionResultAsync(Constants.PackagesFolderName, fileName);
        }

        public Task DeletePackageFileAsync(string id, string version)
        {
            if (String.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("id");
            }

            if (String.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentNullException("version");
            }

            var fileName = BuildFileName(id, version);
            return _fileStorageService.DeleteFileAsync(Constants.PackagesFolderName, fileName);
        }

        public Task SavePackageFileAsync(Package package, Stream packageFile)
        {
            if (packageFile == null)
            {
                throw new ArgumentNullException("packageFile");
            }

            var fileName = BuildFileName(package);
            return _fileStorageService.SaveFileAsync(Constants.PackagesFolderName, fileName, packageFile);
        }

        public Task<Stream> DownloadPackageFileAsync(Package package)
        {
            var fileName = BuildFileName(package);
            return _fileStorageService.GetFileAsync(Constants.PackagesFolderName, fileName);
        }

        private static string BuildFileName(string id, string version)
        {
            return String.Format(
                CultureInfo.InvariantCulture,
                Constants.PackageFileSavePathTemplate,
                id,
                version,
                Constants.NuGetPackageFileExtension);
        }

        private static string BuildFileName(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            if (package.PackageRegistration == null || 
                String.IsNullOrWhiteSpace(package.PackageRegistration.Id) || 
                String.IsNullOrWhiteSpace(package.Version))
            {
                throw new ArgumentException("The package is missing required data.", "package");
            }

            return BuildFileName(package.PackageRegistration.Id, package.Version);
        }
    }
}
{'fraction_non_alphanumeric': 0.06907781967775112, 'fraction_numerical': 0.0, 'mean_word_length': 2.1103411513859274, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3383800', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1292, 'n_words': 270}