@@ -366,50 +366,58 @@ package object extension {
366
366
)(implicit ec : ExecutionContext ): Future [ReplaceAllObjectsResponse ] = {
367
367
val tmpIndexName = s " ${indexName}_tmp_ ${scala.util.Random .nextInt(100 )}"
368
368
369
- for {
370
- copy <- client.operationIndex(
371
- indexName = indexName,
372
- operationIndexParams = OperationIndexParams (
373
- operation = OperationType .Copy ,
374
- destination = tmpIndexName,
375
- scope = Some (Seq (ScopeType .Settings , ScopeType .Rules , ScopeType .Synonyms ))
376
- ),
377
- requestOptions = requestOptions
378
- )
369
+ try {
370
+ for {
371
+ copy <- client.operationIndex(
372
+ indexName = indexName,
373
+ operationIndexParams = OperationIndexParams (
374
+ operation = OperationType .Copy ,
375
+ destination = tmpIndexName,
376
+ scope = Some (Seq (ScopeType .Settings , ScopeType .Rules , ScopeType .Synonyms ))
377
+ ),
378
+ requestOptions = requestOptions
379
+ )
379
380
380
- batchResponses <- chunkedBatch(
381
- indexName = tmpIndexName,
382
- objects = objects,
383
- action = Action .AddObject ,
384
- waitForTasks = true ,
385
- batchSize = batchSize,
386
- requestOptions = requestOptions
387
- )
381
+ batchResponses <- chunkedBatch(
382
+ indexName = tmpIndexName,
383
+ objects = objects,
384
+ action = Action .AddObject ,
385
+ waitForTasks = true ,
386
+ batchSize = batchSize,
387
+ requestOptions = requestOptions
388
+ )
388
389
389
- _ <- client.waitTask(indexName = tmpIndexName, taskID = copy.taskID, requestOptions = requestOptions)
390
+ _ <- client.waitTask(indexName = tmpIndexName, taskID = copy.taskID, requestOptions = requestOptions)
390
391
391
- copy <- client.operationIndex(
392
- indexName = indexName,
393
- operationIndexParams = OperationIndexParams (
394
- operation = OperationType .Copy ,
395
- destination = tmpIndexName,
396
- scope = Some (Seq (ScopeType .Settings , ScopeType .Rules , ScopeType .Synonyms ))
397
- ),
398
- requestOptions = requestOptions
399
- )
400
- _ <- client.waitTask(indexName = tmpIndexName, taskID = copy.taskID, requestOptions = requestOptions)
392
+ copy <- client.operationIndex(
393
+ indexName = indexName,
394
+ operationIndexParams = OperationIndexParams (
395
+ operation = OperationType .Copy ,
396
+ destination = tmpIndexName,
397
+ scope = Some (Seq (ScopeType .Settings , ScopeType .Rules , ScopeType .Synonyms ))
398
+ ),
399
+ requestOptions = requestOptions
400
+ )
401
+ _ <- client.waitTask(indexName = tmpIndexName, taskID = copy.taskID, requestOptions = requestOptions)
401
402
402
- move <- client.operationIndex(
403
- indexName = tmpIndexName,
404
- operationIndexParams = OperationIndexParams (operation = OperationType .Move , destination = indexName),
405
- requestOptions = requestOptions
403
+ move <- client.operationIndex(
404
+ indexName = tmpIndexName,
405
+ operationIndexParams = OperationIndexParams (operation = OperationType .Move , destination = indexName),
406
+ requestOptions = requestOptions
407
+ )
408
+ _ <- client.waitTask(indexName = tmpIndexName, taskID = move.taskID, requestOptions = requestOptions)
409
+ } yield ReplaceAllObjectsResponse (
410
+ copyOperationResponse = copy,
411
+ batchResponses = batchResponses,
412
+ moveOperationResponse = move
406
413
)
407
- _ <- client.waitTask(indexName = tmpIndexName, taskID = move.taskID, requestOptions = requestOptions)
408
- } yield ReplaceAllObjectsResponse (
409
- copyOperationResponse = copy,
410
- batchResponses = batchResponses,
411
- moveOperationResponse = move
412
- )
414
+ } catch {
415
+ case e : Throwable => {
416
+ client.deleteIndex(tmpIndexName)
417
+
418
+ throw e
419
+ }
420
+ }
413
421
}
414
422
415
423
/** Check if an index exists.
0 commit comments