Skip to content

Commit

Permalink
NuGet Job, don't rethrow exceptions if blob is not found (#10188)
Browse files Browse the repository at this point in the history
* Blob not found exception handle properly
  • Loading branch information
erdembayar authored Sep 24, 2024
1 parent 6e639f3 commit a382525
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Catalog/Persistence/AzureStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ protected override async Task OnDeleteAsync(Uri resourceUri, DeleteRequestOption
string blobName = GetName(resourceUri);
BlobRequestConditions accessCondition = (deleteRequestOptions as DeleteRequestOptionsWithAccessCondition)?.BlobRequestConditions;
BlockBlobClient blobClient = GetBlockBlobReference(blobName);
await blobClient.DeleteAsync(DeleteSnapshotsOption.IncludeSnapshots, accessCondition, cancellationToken);
await blobClient.DeleteIfExistsAsync(DeleteSnapshotsOption.IncludeSnapshots, accessCondition, cancellationToken);
}

public override Uri GetUri(string name)
Expand Down
18 changes: 3 additions & 15 deletions src/Catalog/Persistence/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Newtonsoft.Json;
using NuGetGallery;

namespace NuGet.Services.Metadata.Catalog.Persistence
{
Expand Down Expand Up @@ -125,21 +125,9 @@ public async Task DeleteAsync(Uri resourceUri, CancellationToken cancellationTok
{
await OnDeleteAsync(resourceUri, deleteRequestOptions, cancellationToken);
}
catch (CloudBlobStorageException e)
catch (RequestFailedException e) when (e.Status == (int)HttpStatusCode.NotFound)
{
WebException webException = e.InnerException as WebException;
if (webException != null)
{
HttpStatusCode statusCode = ((HttpWebResponse)webException.Response).StatusCode;
if (statusCode != HttpStatusCode.NotFound)
{
throw;
}
}
else
{
throw;
}
// continue
}
catch (Exception e)
{
Expand Down

0 comments on commit a382525

Please sign in to comment.