Merge pull request #2804 from dotnet/piotrpMSFT/AzurePublisher
Azure Publisher: TryDeleteBlob
This commit is contained in:
commit
2827ef208a
2 changed files with 17 additions and 1 deletions
|
@ -75,7 +75,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
else
|
||||
{
|
||||
// This is an old drop of latest so remove all old files to ensure a clean state
|
||||
AzurePublisherTool.ListBlobs($"{targetContainer}").ToList().ForEach(f => AzurePublisherTool.DeleteBlob(f));
|
||||
AzurePublisherTool.ListBlobs($"{targetContainer}").ToList().ForEach(f => AzurePublisherTool.TryDeleteBlob(f));
|
||||
|
||||
// Drop the version file signaling such for any race-condition builds (see above comment).
|
||||
AzurePublisherTool.DropLatestSpecifiedVersion(targetVersionFile);
|
||||
|
|
|
@ -139,6 +139,22 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
|
||||
public bool TryDeleteBlob(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteBlob(path);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Deleting blob {path} failed with \r\n{e.Message}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlob(string path)
|
||||
{
|
||||
_blobContainer.GetBlockBlobReference(path).DeleteAsync().Wait();
|
||||
|
|
Loading…
Add table
Reference in a new issue