Fixing how we clean the file when it fails to download. We were doing it inside the using statement, so it still had a lock to the file and failed to delete it.

This commit is contained in:
Livar Cunha 2016-11-09 10:05:05 -08:00
parent 087852b1b8
commit de0ca4823f

View file

@ -34,19 +34,19 @@ namespace Microsoft.DotNet.Cli.Build
{
var getTask = httpClient.GetStreamAsync(Uri);
using (var outStream = File.Create(DestinationPath))
{
try
{
using (var outStream = File.Create(DestinationPath))
{
getTask.Result.CopyTo(outStream);
}
}
catch (Exception)
{
File.Delete(DestinationPath);
throw;
}
}
}
return true;
}