コード例 #1
0
        public async Task StartValidationAsync(SymbolPackage symbolPackage)
        {
            var symbolPackageStatus = await _symbolPackageValidationInitiator.StartValidationAsync(symbolPackage);

            await _symbolPackageService.UpdateStatusAsync(symbolPackage,
                                                          symbolPackageStatus,
                                                          commitChanges: false);
        }
コード例 #2
0
        public async Task DeleteSymbolsPackageAsync(SymbolPackage symbolPackage)
        {
            if (symbolPackage == null)
            {
                throw new ArgumentNullException(nameof(symbolPackage));
            }

            if (await _symbolPackageFileService.DoesPackageFileExistAsync(symbolPackage.Package))
            {
                await _symbolPackageFileService.DeletePackageFileAsync(symbolPackage.Id, symbolPackage.Version);
            }

            await _symbolPackageService.UpdateStatusAsync(symbolPackage, PackageStatus.Deleted, commitChanges : true);
        }
コード例 #3
0
 private async Task UpdateSymbolPackageInternalAsync(SymbolPackage symbolPackage, PackageStatus symbolPackageStatus)
 {
     await _symbolPackageService.UpdateStatusAsync(symbolPackage,
                                                   symbolPackageStatus,
                                                   commitChanges : false);
 }
コード例 #4
0
        public async Task SoftDeletePackagesAsync(IEnumerable <Package> packages, User deletedBy, string reason, string signature)
        {
            using (var strategy = new SuspendDbExecutionStrategy())
                using (var transaction = _entitiesContext.GetDatabase().BeginTransaction())
                {
                    // Increase command timeout
                    _entitiesContext.SetCommandTimeout(seconds: 300);

                    // Keep package registrations
                    var packageRegistrations = packages
                                               .GroupBy(p => p.PackageRegistration)
                                               .Select(g => g.First().PackageRegistration)
                                               .ToList();

                    // Backup the package binaries and remove from main storage
                    // We're doing this early in the process as we need the metadata to still exist in the DB.
                    await BackupPackageBinaries(packages);

                    // Store the soft delete in the database
                    var packageDelete = new PackageDelete
                    {
                        DeletedOn = DateTime.UtcNow,
                        DeletedBy = deletedBy,
                        Reason    = reason,
                        Signature = signature
                    };

                    foreach (var package in packages)
                    {
                        /// We do not call <see cref="IPackageService.MarkPackageUnlistedAsync(Package, bool)"/> here
                        /// because that writes an audit entry. Additionally, the latest bits are already updated by
                        /// the package status change.
                        package.Listed = false;

                        await _packageService.UpdatePackageStatusAsync(
                            package,
                            PackageStatus.Deleted,
                            commitChanges : false);

                        UnlinkPackageDeprecations(package);

                        // Mark all associated symbol packages for deletion.
                        foreach (var symbolPackage in package.SymbolPackages)
                        {
                            await _symbolPackageService.UpdateStatusAsync(
                                symbolPackage,
                                PackageStatus.Deleted,
                                commitChanges : false);
                        }

                        packageDelete.Packages.Add(package);

                        await _auditingService.SaveAuditRecordAsync(CreateAuditRecord(package, package.PackageRegistration, AuditedPackageAction.SoftDelete, reason));

                        _telemetryService.TrackPackageDelete(package, isHardDelete: false);
                    }

                    _packageDeletesRepository.InsertOnCommit(packageDelete);

                    // Commit changes
                    await _packageRepository.CommitChangesAsync();

                    await _symbolPackageRepository.CommitChangesAsync();

                    await _packageDeletesRepository.CommitChangesAsync();

                    transaction.Commit();
                }

            // Force refresh the index
            UpdateSearchIndex();
        }