MCPcopy
hub / github.com/apache/pouchdb / completeReplication

Function completeReplication

lib/index.es.js:10029–10066  ·  view source on GitHub ↗
(fatalError)

Source from the content-addressed store, hash-verified

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