示例#1
0
文件: Catalog.cs 项目: skarllot/Sleet
        /// <summary>
        /// Add a package to the catalog.
        /// </summary>
        public async Task AddPackageAsync(PackageInput packageInput)
        {
            // Create package details page
            var addFileList = _context.SourceSettings.CatalogEnabled;

            var packageDetails = await CatalogUtility.CreatePackageDetailsAsync(packageInput, CatalogBaseURI, _context.CommitId, addFileList);

            var packageDetailsUri = JsonUtility.GetIdUri(packageDetails);

            // Add output to the package input for other services to use.
            packageInput.PackageDetails = packageDetails;

            var packageDetailsFile = _context.Source.Get(packageDetailsUri);
            await packageDetailsFile.Write(packageDetails, _context.Log, _context.Token);

            // Create commit
            var pageCommit = CatalogUtility.CreatePageCommit(
                packageInput.Identity,
                packageDetailsUri,
                _context.CommitId,
                SleetOperation.Add,
                "nuget:PackageDetails");

            await AddCatalogEntry(pageCommit, "nuget:lastCreated");
        }
示例#2
0
        /// <summary>
        /// Add a remove entry and return the page commit.
        /// </summary>
        private async Task <JObject> GetRemoveCommit(PackageIdentity package)
        {
            // Create package details page for the delete
            var packageDetails = await CatalogUtility.CreateDeleteDetailsAsync(package, string.Empty, CatalogBaseURI, _context.CommitId);

            var packageDetailsFile = _context.Source.Get(packageDetails.GetEntityId());

            await packageDetailsFile.Write(packageDetails, _context.Log, _context.Token);

            // Create commit
            return(CatalogUtility.CreatePageCommit(
                       package,
                       packageDetailsFile.EntityUri,
                       _context.CommitId,
                       SleetOperation.Remove,
                       "nuget:PackageDelete"));
        }
示例#3
0
文件: Catalog.cs 项目: skarllot/Sleet
        public async Task RemovePackageAsync(PackageIdentity package)
        {
            // Create package details page for the delete
            var packageDetails = await CatalogUtility.CreateDeleteDetailsAsync(package, string.Empty, CatalogBaseURI, _context.CommitId);

            var packageDetailsFile = _context.Source.Get(packageDetails.GetEntityId());

            await packageDetailsFile.Write(packageDetails, _context.Log, _context.Token);

            // Create commit
            var pageCommit = CatalogUtility.CreatePageCommit(
                package,
                packageDetailsFile.EntityUri,
                _context.CommitId,
                SleetOperation.Remove,
                "nuget:PackageDelete");

            await AddCatalogEntry(pageCommit, "nuget:lastDeleted");
        }
示例#4
0
        /// <summary>
        /// Adds a catalog page and returns the commit.
        /// </summary>
        private async Task <JObject> AddPackageToCatalogAndGetCommit(PackageInput packageInput)
        {
            // Create package details page
            var nupkgUri       = packageInput.GetNupkgUri(_context);
            var packageDetails = await CatalogUtility.CreatePackageDetailsAsync(packageInput, CatalogBaseURI, nupkgUri, _context.CommitId, writeFileList : true);

            var packageDetailsUri = JsonUtility.GetIdUri(packageDetails);

            // Add output to the package input for other services to use.
            packageInput.PackageDetails = packageDetails;

            var packageDetailsFile = _context.Source.Get(packageDetailsUri);
            await packageDetailsFile.Write(packageDetails, _context.Log, _context.Token);

            // Create commit
            return(CatalogUtility.CreatePageCommit(
                       packageInput.Identity,
                       packageDetailsUri,
                       _context.CommitId,
                       SleetOperation.Add,
                       "nuget:PackageDetails"));
        }