Exemplo n.º 1
0
        /// <inheritdoc />
        public async Task <Result <ContentHashListWithCacheMetadata> > GetContentHashListAsync(
            Context context,
            string cacheNamespace,
            StrongFingerprint strongFingerprint)
        {
            try
            {
                ContentHashListResponse response =
                    await ArtifactHttpClientErrorDetectionStrategy.ExecuteWithTimeoutAsync(
                        context,
                        "GetContentHashList",
                        innerCts => _buildCacheHttpClient.GetContentHashListAsync(cacheNamespace, strongFingerprint),
                        CancellationToken.None).ConfigureAwait(false);

                DownloadUriCache.Instance.BulkAddDownloadUris(response.BlobDownloadUris);

                // our response should never be null.
                if (response.ContentHashListWithCacheMetadata != null)
                {
                    return(new Result <ContentHashListWithCacheMetadata>(response.ContentHashListWithCacheMetadata));
                }

                return(new Result <ContentHashListWithCacheMetadata>(EmptyContentHashList));
            }
            catch (CacheServiceException ex) when(ex.ReasonCode == CacheErrorReasonCode.ContentHashListNotFound)
            {
                return(new Result <ContentHashListWithCacheMetadata>(EmptyContentHashList));
            }
            catch (ContentBagNotFoundException)
            {
                return(new Result <ContentHashListWithCacheMetadata>(EmptyContentHashList));
            }
            catch (VssServiceResponseException serviceEx) when(serviceEx.HttpStatusCode == HttpStatusCode.NotFound)
            {
                // Currently expect the Item-based service to return VssServiceResponseException on misses,
                // but the other catches have been left for safety/compat.
                return(new Result <ContentHashListWithCacheMetadata>(EmptyContentHashList));
            }
            catch (Exception ex)
            {
                return(new Result <ContentHashListWithCacheMetadata>(ex));
            }
        }