Method GetOrAddVariantAsync
GetOrAddVariantAsync(FileId, string, IFileProcessingPipelineSelector, CancellationToken)
Adds the variants of a tree (a top-level variant and any nested variants declared by the pipeline) that do not exist yet, and returns every variant in the tree, whether it was added now or existed already.
Declaration
TaskWithProgress<IReadOnlyList<IRepoFile>> GetOrAddVariantAsync(FileId fileId, string variantId, IFileProcessingPipelineSelector pipeline, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| FileId | fileId | The ID of the main file to which the variants are added. |
| string | variantId | The ID of the top-level variant. |
| IFileProcessingPipelineSelector | pipeline | The processing pipeline for the top-level variant, or the selector that chooses one by extension. |
| CancellationToken | cancellationToken | A cancellation token that cancels the operation. |
Returns
| Type | Description |
|---|---|
| TaskWithProgress<IReadOnlyList<IRepoFile>> | Every variant in the tree in the same order as AddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken). |
Remarks
Existing variants are returned unchanged and their pipelines do not run. This is the method to use for variants that are generated on demand.
The variants this call added know their sizes without storage access or a network round trip, while those that already existed may read theirs on demand (see GetLengthAsync(CancellationToken)).
Exceptions
| Type | Condition |
|---|---|
| RepoVariantPendingCleanupException | A variant in the requested tree was retired and has not been cleaned up yet. |
| RepoFileNotFoundException | The file or the source variant does not exist. |
| FileProcessingException | A processor in the pipeline rejected or failed to process the source. |
GetOrAddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken)
Adds the variants of a tree (a top-level variant and any nested variants declared by the pipeline) that do not exist yet, and returns every variant in the tree, whether it was added now or existed already.
Declaration
TaskWithProgress<IReadOnlyList<IRepoFile>> GetOrAddVariantAsync(FileId fileId, string variantId, string? sourceVariantId, IFileProcessingPipelineSelector pipeline, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| FileId | fileId | The ID of the main file to which the variants are added. |
| string | variantId | The ID of the top-level variant. |
| string | sourceVariantId | The ID of the variant to process, or null to process the main file. |
| IFileProcessingPipelineSelector | pipeline | The processing pipeline for the top-level variant, or the selector that chooses one by extension. |
| CancellationToken | cancellationToken | A cancellation token that cancels the operation. |
Returns
| Type | Description |
|---|---|
| TaskWithProgress<IReadOnlyList<IRepoFile>> | Every variant in the tree in the same order as AddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken). |
Remarks
Existing variants are returned unchanged and their pipelines do not run. This is the method to use for variants that are generated on demand.
The variants this call added know their sizes without storage access or a network round trip, while those that already existed may read theirs on demand (see GetLengthAsync(CancellationToken)).
Exceptions
| Type | Condition |
|---|---|
| RepoVariantPendingCleanupException | A variant in the requested tree was retired and has not been cleaned up yet. |
| RepoFileNotFoundException | The file or the source variant does not exist. |
| FileProcessingException | A processor in the pipeline rejected or failed to process the source. |