File tree 1 file changed +13
-14
lines changed
1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -453,27 +453,26 @@ private async Task Start(CancellationToken ct = default)
453
453
if ( res . Content . Headers . ContentLength >= 0 )
454
454
TotalBytes = ( ulong ) res . Content . Headers . ContentLength ;
455
455
456
- FileStream tempFile ;
457
- try
458
- {
459
- tempFile = File . Create ( TempDestinationPath , BufferSize ,
460
- FileOptions . Asynchronous | FileOptions . SequentialScan ) ;
461
- }
462
- catch ( Exception e )
463
- {
464
- _logger . LogError ( e , "Failed to create temporary file '{TempDestinationPath}'" , TempDestinationPath ) ;
465
- throw ;
466
- }
467
-
468
- await Download ( res , tempFile , ct ) ;
456
+ await Download ( res , ct ) ;
469
457
return ;
470
458
}
471
459
472
- private async Task Download ( HttpResponseMessage res , FileStream tempFile , CancellationToken ct )
460
+ private async Task Download ( HttpResponseMessage res , CancellationToken ct )
473
461
{
474
462
try
475
463
{
476
464
var sha1 = res . Headers . Contains ( "ETag" ) ? SHA1 . Create ( ) : null ;
465
+ FileStream tempFile ;
466
+ try
467
+ {
468
+ tempFile = File . Create ( TempDestinationPath , BufferSize ,
469
+ FileOptions . Asynchronous | FileOptions . SequentialScan ) ;
470
+ }
471
+ catch ( Exception e )
472
+ {
473
+ _logger . LogError ( e , "Failed to create temporary file '{TempDestinationPath}'" , TempDestinationPath ) ;
474
+ throw ;
475
+ }
477
476
await using ( tempFile )
478
477
{
479
478
var stream = await res . Content . ReadAsStreamAsync ( ct ) ;
You can’t perform that action at this time.
0 commit comments