@@ -945,14 +945,17 @@ public extension Sequence where Element: ParseInstallation {
945
945
options. insert ( . cachePolicy( . reloadIgnoringLocalCacheData) )
946
946
var childObjects = [ String: PointerType] ( )
947
947
var childFiles = [ UUID: ParseFile] ( )
948
+ var commands = [ API . Command < Self . Element , Self . Element > ] ( )
948
949
var error : ParseError ?
949
950
950
- let installations = map { $0 }
951
- for installation in installations {
951
+ try forEach {
952
+ let installation = $0
952
953
let group = DispatchGroup ( )
953
954
group. enter ( )
954
- installation. ensureDeepSave ( options: options) { ( savedChildObjects, savedChildFiles, parseError) -> Void in
955
- //If an error occurs, everything should be skipped
955
+ installation. ensureDeepSave ( options: options,
956
+ // swiftlint:disable:next line_length
957
+ isShouldReturnIfChildObjectsFound: transaction) { ( savedChildObjects, savedChildFiles, parseError) -> Void in
958
+ // If an error occurs, everything should be skipped
956
959
if parseError != nil {
957
960
error = parseError
958
961
}
@@ -984,12 +987,10 @@ public extension Sequence where Element: ParseInstallation {
984
987
if let error = error {
985
988
throw error
986
989
}
990
+ commands. append ( try installation. saveCommand ( ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig) )
987
991
}
988
992
989
993
var returnBatch = [ ( Result < Self . Element , ParseError > ) ] ( )
990
- let commands = try map {
991
- try $0. saveCommand ( ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig)
992
- }
993
994
let batchLimit = limit != nil ? limit! : ParseConstants . batchLimit
994
995
try canSendTransactions ( transaction, objectCount: commands. count, batchLimit: batchLimit)
995
996
let batches = BatchUtils . splitArray ( commands, valuesPerSegment: batchLimit)
@@ -1171,16 +1172,17 @@ public extension Sequence where Element: ParseInstallation {
1171
1172
var childObjects = [ String: PointerType] ( )
1172
1173
var childFiles = [ UUID: ParseFile] ( )
1173
1174
var error : ParseError ?
1174
-
1175
+ var commands = [ API . Command < Self . Element , Self . Element > ] ( )
1175
1176
let installations = map { $0 }
1177
+
1176
1178
for installation in installations {
1177
1179
let group = DispatchGroup ( )
1178
1180
group. enter ( )
1179
1181
installation
1180
1182
. ensureDeepSave ( options: options,
1181
1183
// swiftlint:disable:next line_length
1182
- isShouldReturnIfChildObjectsFound: true ) { ( savedChildObjects, savedChildFiles, parseError) -> Void in
1183
- //If an error occurs, everything should be skipped
1184
+ isShouldReturnIfChildObjectsFound: transaction ) { ( savedChildObjects, savedChildFiles, parseError) -> Void in
1185
+ // If an error occurs, everything should be skipped
1184
1186
if parseError != nil {
1185
1187
error = parseError
1186
1188
}
@@ -1215,23 +1217,34 @@ public extension Sequence where Element: ParseInstallation {
1215
1217
}
1216
1218
return
1217
1219
}
1220
+
1221
+ do {
1222
+ switch method {
1223
+ case . save:
1224
+ commands. append (
1225
+ try installation. saveCommand ( ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig)
1226
+ )
1227
+ case . create:
1228
+ commands. append ( installation. createCommand ( ) )
1229
+ case . replace:
1230
+ commands. append ( try installation. replaceCommand ( ) )
1231
+ case . update:
1232
+ commands. append ( try installation. updateCommand ( ) )
1233
+ }
1234
+ } catch {
1235
+ callbackQueue. async {
1236
+ if let parseError = error as? ParseError {
1237
+ completion ( . failure( parseError) )
1238
+ } else {
1239
+ completion ( . failure( . init( code: . unknownError, message: error. localizedDescription) ) )
1240
+ }
1241
+ }
1242
+ return
1243
+ }
1218
1244
}
1219
1245
1220
1246
do {
1221
1247
var returnBatch = [ ( Result < Self . Element , ParseError > ) ] ( )
1222
- let commands : [ API . Command < Self . Element , Self . Element > ] !
1223
- switch method {
1224
- case . save:
1225
- commands = try map {
1226
- try $0. saveCommand ( ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig)
1227
- }
1228
- case . create:
1229
- commands = map { $0. createCommand ( ) }
1230
- case . replace:
1231
- commands = try map { try $0. replaceCommand ( ) }
1232
- case . update:
1233
- commands = try map { try $0. updateCommand ( ) }
1234
- }
1235
1248
1236
1249
let batchLimit = limit != nil ? limit! : ParseConstants . batchLimit
1237
1250
try canSendTransactions ( transaction, objectCount: commands. count, batchLimit: batchLimit)
0 commit comments