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,17 +34,17 @@ namespace Microsoft.DotNet.Cli.Build
{ {
var getTask = httpClient.GetStreamAsync(Uri); var getTask = httpClient.GetStreamAsync(Uri);
using (var outStream = File.Create(DestinationPath)) try
{ {
try using (var outStream = File.Create(DestinationPath))
{ {
getTask.Result.CopyTo(outStream); getTask.Result.CopyTo(outStream);
} }
catch (Exception) }
{ catch (Exception)
File.Delete(DestinationPath); {
throw; File.Delete(DestinationPath);
} throw;
} }
} }