Skip to content

Commit a382525

Browse files
authored
NuGet Job, don't rethrow exceptions if blob is not found (#10188)
* Blob not found exception handle properly
1 parent 6e639f3 commit a382525

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

src/Catalog/Persistence/AzureStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ protected override async Task OnDeleteAsync(Uri resourceUri, DeleteRequestOption
421421
string blobName = GetName(resourceUri);
422422
BlobRequestConditions accessCondition = (deleteRequestOptions as DeleteRequestOptionsWithAccessCondition)?.BlobRequestConditions;
423423
BlockBlobClient blobClient = GetBlockBlobReference(blobName);
424-
await blobClient.DeleteAsync(DeleteSnapshotsOption.IncludeSnapshots, accessCondition, cancellationToken);
424+
await blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots, accessCondition, cancellationToken);
425425
}
426426

427427
public override Uri GetUri(string name)

src/Catalog/Persistence/Storage.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using System.Net;
99
using System.Threading;
1010
using System.Threading.Tasks;
11+
using Azure;
1112
using Newtonsoft.Json;
12-
using NuGetGallery;
1313

1414
namespace NuGet.Services.Metadata.Catalog.Persistence
1515
{
@@ -125,21 +125,9 @@ public async Task DeleteAsync(Uri resourceUri, CancellationToken cancellationTok
125125
{
126126
await OnDeleteAsync(resourceUri, deleteRequestOptions, cancellationToken);
127127
}
128-
catch (CloudBlobStorageException e)
128+
catch (RequestFailedException e) when (e.Status == (int)HttpStatusCode.NotFound)
129129
{
130-
WebException webException = e.InnerException as WebException;
131-
if (webException != null)
132-
{
133-
HttpStatusCode statusCode = ((HttpWebResponse)webException.Response).StatusCode;
134-
if (statusCode != HttpStatusCode.NotFound)
135-
{
136-
throw;
137-
}
138-
}
139-
else
140-
{
141-
throw;
142-
}
130+
// continue
143131
}
144132
catch (Exception e)
145133
{

0 commit comments

Comments
 (0)