@@ -494,37 +494,46 @@ public async Task<ReplaceAllObjectsResponse> ReplaceAllObjectsAsync<T>(string in
494
494
var rnd = new Random ( ) ;
495
495
var tmpIndexName = $ "{ indexName } _tmp_{ rnd . Next ( 100 ) } ";
496
496
497
- var copyResponse = await OperationIndexAsync ( indexName ,
498
- new OperationIndexParams ( OperationType . Copy , tmpIndexName )
499
- { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
500
- . ConfigureAwait ( false ) ;
497
+ try
498
+ {
499
+ var copyResponse = await OperationIndexAsync ( indexName ,
500
+ new OperationIndexParams ( OperationType . Copy , tmpIndexName )
501
+ { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
502
+ . ConfigureAwait ( false ) ;
501
503
502
- var batchResponse = await ChunkedBatchAsync ( tmpIndexName , objects , Action . AddObject , true , batchSize ,
503
- options , cancellationToken ) . ConfigureAwait ( false ) ;
504
+ var batchResponse = await ChunkedBatchAsync ( tmpIndexName , objects , Action . AddObject , true , batchSize ,
505
+ options , cancellationToken ) . ConfigureAwait ( false ) ;
504
506
505
- await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
506
- . ConfigureAwait ( false ) ;
507
+ await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
508
+ . ConfigureAwait ( false ) ;
507
509
508
- copyResponse = await OperationIndexAsync ( indexName ,
509
- new OperationIndexParams ( OperationType . Copy , tmpIndexName )
510
- { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
511
- . ConfigureAwait ( false ) ;
512
- await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
513
- . ConfigureAwait ( false ) ;
510
+ copyResponse = await OperationIndexAsync ( indexName ,
511
+ new OperationIndexParams ( OperationType . Copy , tmpIndexName )
512
+ { Scope = [ ScopeType . Settings , ScopeType . Rules , ScopeType . Synonyms ] } , options , cancellationToken )
513
+ . ConfigureAwait ( false ) ;
514
+ await WaitForTaskAsync ( tmpIndexName , copyResponse . TaskID , requestOptions : options , ct : cancellationToken )
515
+ . ConfigureAwait ( false ) ;
514
516
515
- var moveResponse = await OperationIndexAsync ( tmpIndexName ,
516
- new OperationIndexParams ( OperationType . Move , indexName ) , options , cancellationToken )
517
- . ConfigureAwait ( false ) ;
517
+ var moveResponse = await OperationIndexAsync ( tmpIndexName ,
518
+ new OperationIndexParams ( OperationType . Move , indexName ) , options , cancellationToken )
519
+ . ConfigureAwait ( false ) ;
518
520
519
- await WaitForTaskAsync ( tmpIndexName , moveResponse . TaskID , requestOptions : options , ct : cancellationToken )
520
- . ConfigureAwait ( false ) ;
521
+ await WaitForTaskAsync ( tmpIndexName , moveResponse . TaskID , requestOptions : options , ct : cancellationToken )
522
+ . ConfigureAwait ( false ) ;
521
523
522
- return new ReplaceAllObjectsResponse
524
+ return new ReplaceAllObjectsResponse
525
+ {
526
+ CopyOperationResponse = copyResponse ,
527
+ MoveOperationResponse = moveResponse ,
528
+ BatchResponses = batchResponse
529
+ } ;
530
+ }
531
+ catch ( Exception ex )
523
532
{
524
- CopyOperationResponse = copyResponse ,
525
- MoveOperationResponse = moveResponse ,
526
- BatchResponses = batchResponse
527
- } ;
533
+ await DeleteIndexAsync ( tmpIndexName , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
534
+
535
+ throw ex ;
536
+ }
528
537
}
529
538
530
539
/// <inheritdoc/>
0 commit comments