private IndexAction <KeyedDocument> GetHijackIndexAction( string packageId, Package package, HijackDocumentChanges changes) { if (!changes.UpdateMetadata) { throw new ArgumentException( "The hijack document changes must be set to update metadata.", nameof(changes)); } VerifyConsistency(packageId, package); return(IndexAction.Upload <KeyedDocument>(_hijack.FullFromDb( packageId, changes, package))); }
private IndexAction <KeyedDocument> GetHijackIndexAction( Context context, NuGetVersion version, HijackDocumentChanges changes) { IndexAction <KeyedDocument> indexAction; if (changes.Delete) { indexAction = IndexAction.Delete(_hijack.Keyed( context.PackageId, version.ToNormalizedString())); } else if (!changes.UpdateMetadata) { indexAction = IndexAction.Merge <KeyedDocument>(_hijack.LatestFromCatalog( context.PackageId, version.ToNormalizedString(), lastCommitTimestamp: context.LastCommitTimestamp, lastCommitId: context.LastCommitId, changes: changes)); } else { var leaf = context.GetLeaf(version); var normalizedVersion = VerifyConsistencyAndNormalizeVersion(context, leaf); indexAction = IndexAction.MergeOrUpload <KeyedDocument>(_hijack.FullFromCatalog( normalizedVersion, changes, leaf)); } _logger.LogInformation( "Hijack index action prepared for {PackageId} {PackageVersion}: {IndexAction} with a {DocumentType} document.", context.PackageId, version.ToNormalizedString(), indexAction.ActionType, indexAction.Document.GetType().FullName); return(indexAction); }