private async Task ProcessEmbeddedIconAsync(IStorage destinationStorage, CatalogCommitItem item, string iconFile, CancellationToken cancellationToken) { var packageFilename = PackageUtility.GetPackageFileName(item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString()).ToLowerInvariant(); var packageUri = _packageStorage.ResolveUri(packageFilename); var packageBlobReference = await _packageStorage.GetCloudBlockBlobReferenceAsync(packageUri); using (_telemetryService.TrackEmbeddedIconProcessingDuration(item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString())) { Stream packageStream; try { packageStream = await packageBlobReference.GetStreamAsync(cancellationToken); } catch (StorageException ex) when(ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound) { _logger.LogWarning("Package blob not found at {PackageUrl}: {Exception}. Will assume package was deleted and skip", packageUri.AbsoluteUri, ex); return; } catch (Exception ex) { // logging other exceptions here to have proper scope in log message _logger.LogError("Exception while trying to access package blob {PackageUrl}: {Exception}", packageUri.AbsoluteUri, ex); throw; } using (packageStream) { var targetStoragePath = GetTargetStorageIconPath(item); var resultUrl = await _iconProcessor.CopyEmbeddedIconFromPackageAsync( packageStream, iconFile, destinationStorage, targetStoragePath, cancellationToken, item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString()); } } }
private async Task ProcessEmbeddedIconAsync(IStorage destinationStorage, CatalogCommitItem item, string iconFile, CancellationToken cancellationToken) { var packageFilename = PackageUtility.GetPackageFileName(item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString()).ToLowerInvariant(); var packageUri = _packageStorage.ResolveUri(packageFilename); var packageBlobReference = await _packageStorage.GetCloudBlockBlobReferenceAsync(packageUri); using (_telemetryService.TrackEmbeddedIconProcessingDuration(item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString())) using (var packageStream = await packageBlobReference.GetStreamAsync(cancellationToken)) { var targetStoragePath = GetTargetStorageIconPath(item); var resultUrl = await _iconProcessor.CopyEmbeddedIconFromPackageAsync( packageStream, iconFile, destinationStorage, targetStoragePath, cancellationToken, item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString()); } }