@@ -394,80 +394,6 @@ - (BOOL)canBeSerializedAfterSaving:(NSMutableArray *)saved withCurrentUser:(PFUs
394
394
}
395
395
}
396
396
397
- // Delete all objects in the array.
398
- + (BFTask *)deleteAllAsync : (NSArray *)objects withSessionToken : (NSString *)sessionToken {
399
- if ([objects count ] == 0 ) {
400
- return [BFTask taskWithResult: @YES ];
401
- }
402
-
403
- return [[[BFTask taskFromExecutor: [BFExecutor defaultPriorityBackgroundExecutor ] withBlock: ^id {
404
- return [PFObject _enqueue: ^BFTask *(BFTask *toAwait) {
405
- NSMutableSet *uniqueObjects = [NSMutableSet set ];
406
- NSMutableArray *commands = [NSMutableArray arrayWithCapacity: [objects count ]];
407
- for (PFObject *object in objects) {
408
- @synchronized (object->lock ) {
409
- // Just continue, there is no action to be taken here
410
- if (!object.objectId ) {
411
- continue ;
412
- }
413
-
414
- NSString *uniqueCheck = [NSString stringWithFormat: @" %@ -%@ " ,
415
- object.parseClassName,
416
- [object objectId ]];
417
- if (![uniqueObjects containsObject: uniqueCheck]) {
418
- [object checkDeleteParams ];
419
-
420
- [commands addObject: [object _currentDeleteCommandWithSessionToken: sessionToken]];
421
- [uniqueObjects addObject: uniqueCheck];
422
- }
423
- }
424
- }
425
-
426
- // Batch requests have currently a limit of 50 packaged requests per single request
427
- // This splitting will split the overall array into segments of upto 50 requests
428
- // and execute them concurrently with a wrapper task for all of them.
429
- NSArray *commandBatches = [PFInternalUtils arrayBySplittingArray: commands
430
- withMaximumComponentsPerSegment: PFRESTObjectBatchCommandSubcommandsLimit];
431
- NSMutableArray *tasks = [NSMutableArray arrayWithCapacity: [commandBatches count ]];
432
- for (NSArray *commandBatch in commandBatches) {
433
- PFRESTCommand *command = [PFRESTObjectBatchCommand batchCommandWithCommands: commandBatch
434
- sessionToken: sessionToken];
435
- BFTask *task = [[[Parse _currentManager ].commandRunner runCommandAsync: command withOptions: 0 ]
436
- continueAsyncWithSuccessBlock: ^id (BFTask *task) {
437
- NSArray *results = [task.result result ];
438
- for (NSDictionary *result in results) {
439
- NSDictionary *errorResult = result[@" error" ];
440
- if (errorResult) {
441
- NSError *error = [PFErrorUtilities errorFromResult: errorResult];
442
- return [BFTask taskWithError: error];
443
- }
444
- }
445
-
446
- return task;
447
- }];
448
- [tasks addObject: task];
449
- }
450
- return [BFTask taskForCompletionOfAllTasks: tasks];
451
- } forObjects: objects];
452
- }] continueWithBlock: ^id (BFTask *task) {
453
- if (!task.exception ) {
454
- return task;
455
- }
456
-
457
- // Return the first exception, instead of the aggregated one
458
- // for the sake of compatability with old versions
459
-
460
- if ([task.exception.name isEqualToString: BFTaskMultipleExceptionsException]) {
461
- NSException *firstException = [task.exception.userInfo[@" exceptions" ] firstObject ];
462
- if (firstException) {
463
- return [BFTask taskWithException: firstException];
464
- }
465
- }
466
-
467
- return task;
468
- }] continueWithSuccessResult: @YES ];
469
- }
470
-
471
397
// This saves all of the objects and files reachable from the given object.
472
398
// It does its work in multiple waves, saving as many as possible in each wave.
473
399
// If there's ever an error, it just gives up, sets error, and returns NO;
0 commit comments