(fatalError)
| 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 */ |
no test coverage detected
searching dependent graphs…