MCPcopy Index your code
hub / github.com/apache/pouchdb / completeReplication

Function completeReplication

lib/index.js:10034–10071  ·  view source on GitHub ↗
(fatalError)

Source from the content-addressed store, hash-verified

10032
10033
10034 function completeReplication(fatalError) {
10035 if (replicationCompleted) {
10036 return;
10037 }
10038 /* istanbul ignore if */
10039 if (returnValue.cancelled) {
10040 result.status = 'cancelled';
10041 if (writingCheckpoint) {
10042 return;
10043 }
10044 }
10045 result.status = result.status || 'complete';
10046 result.end_time = new Date().toISOString();
10047 result.last_seq = last_seq;
10048 replicationCompleted = true;
10049
10050 src.activeTasks.remove(taskId, fatalError);
10051
10052 if (fatalError) {
10053 // need to extend the error because Firefox considers ".result" read-only
10054 fatalError = createError(fatalError);
10055 fatalError.result = result;
10056
10057 // Normalize error name. i.e. 'Unauthorized' -> 'unauthorized' (eg Sync Gateway)
10058 var errorName = (fatalError.name || '').toLowerCase();
10059 if (errorName === 'unauthorized' || errorName === 'forbidden') {
10060 returnValue.emit('error', fatalError);
10061 returnValue.removeAllListeners();
10062 } else {
10063 backOff(opts, returnValue, fatalError, function () {
10064 replicate(src, target, opts, returnValue);
10065 });
10066 }
10067 } else {
10068 returnValue.emit('complete', result);
10069 returnValue.removeAllListeners();
10070 }
10071 }
10072
10073 function onChange(change, pending, lastSeq) {
10074 /* istanbul ignore if */

Callers 10

writeDocsFunction · 0.70
finishBatchFunction · 0.70
getDiffsFunction · 0.70
processPendingBatchFunction · 0.70
abortReplicationFunction · 0.70
onChangeFunction · 0.70
onChangesCompleteFunction · 0.70
onChangesErrorFunction · 0.70
startChangesFunction · 0.70
replicateFunction · 0.70

Calls 4

createErrorFunction · 0.70
backOffFunction · 0.70
replicateFunction · 0.70
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…