private async ValueTask <Module> GetModuleAsync(IModuleSource source, ModuleReleaseIdentifier releaseId, CancellationToken cancellation) { var moduleId = releaseId.Module; var moduleVersion = releaseId.Version; Module module; do { module = await _entityStorageEngine.GetByIdAsync <Module>(moduleId.ToString(), cancellation); if (module == null) { var metadata = await source.GetMetadataAsync(releaseId, _metadataReader, cancellation); module = new Module(metadata, source); } else if (module.GetRelease(moduleVersion) is var release && release != null) { if (release.TryAddSource(source)) { break; } } else { var metadata = await source.GetMetadataAsync(releaseId, _metadataReader, cancellation); module.AddRelease(metadata, source); } }while (!await _entityStorageEngine.TryStoreAsync(module, cancellation));
public static ValueTask <IModuleMetadata> GetMetadataAsync(this IModuleSource moduleSource, ModuleReleaseIdentifier moduleRelease, IMetadataReader moduleMetadataReader, CancellationToken cancellation = default) { if (moduleSource == null) { throw new ArgumentNullException(nameof(moduleSource)); } if (moduleRelease == default) { throw new ArgumentDefaultException(nameof(moduleRelease)); } return(moduleSource.GetMetadataAsync(moduleRelease.Module, moduleRelease.Version, moduleMetadataReader, cancellation)); }