(err)
| 1337 | } |
| 1338 | |
| 1339 | function done(err) { |
| 1340 | if (err) return callback(err); |
| 1341 | |
| 1342 | debug('\treplication finished'); |
| 1343 | debug('\t\t%s conflict(s) detected', diff.conflicts.length); |
| 1344 | debug('\t\t%s change(s) applied', updates ? updates.length : 0); |
| 1345 | debug('\t\tnew checkpoints: { source: %j, target: %j }', |
| 1346 | newSourceCp, newTargetCp); |
| 1347 | |
| 1348 | const conflicts = diff.conflicts.map(function(change) { |
| 1349 | return new Change.Conflict( |
| 1350 | change.modelId, sourceModel, targetModel, |
| 1351 | ); |
| 1352 | }); |
| 1353 | |
| 1354 | if (conflicts.length) { |
| 1355 | sourceModel.emit('conflicts', conflicts); |
| 1356 | } |
| 1357 | |
| 1358 | if (callback) { |
| 1359 | const newCheckpoints = {source: newSourceCp, target: newTargetCp}; |
| 1360 | callback(null, conflicts, newCheckpoints, updates); |
| 1361 | } |
| 1362 | } |
| 1363 | } |
| 1364 | |
| 1365 | /** |
no outgoing calls
searching dependent graphs…