File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Expand file tree Collapse file tree 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)
453453 if ( res . Content . Headers . ContentLength >= 0 )
454454 TotalBytes = ( ulong ) res . Content . Headers . ContentLength ;
455455
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 ) ;
469457 return ;
470458 }
471459
472- private async Task Download ( HttpResponseMessage res , FileStream tempFile , CancellationToken ct )
460+ private async Task Download ( HttpResponseMessage res , CancellationToken ct )
473461 {
474462 try
475463 {
476464 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+ }
477476 await using ( tempFile )
478477 {
479478 var stream = await res . Content . ReadAsStreamAsync ( ct ) ;
You can’t perform that action at this time.
0 commit comments