(fatalError)
| 9998 | |
| 9999 | |
| 10000 | function completeReplication(fatalError) { |
| 10001 | if (replicationCompleted) { |
| 10002 | return; |
| 10003 | } |
| 10004 | /* istanbul ignore if */ |
| 10005 | if (returnValue.cancelled) { |
| 10006 | result.status = 'cancelled'; |
| 10007 | if (writingCheckpoint) { |
| 10008 | return; |
| 10009 | } |
| 10010 | } |
| 10011 | result.status = result.status || 'complete'; |
| 10012 | result.end_time = new Date().toISOString(); |
| 10013 | result.last_seq = last_seq; |
| 10014 | replicationCompleted = true; |
| 10015 | |
| 10016 | src.activeTasks.remove(taskId, fatalError); |
| 10017 | |
| 10018 | if (fatalError) { |
| 10019 | // need to extend the error because Firefox considers ".result" read-only |
| 10020 | fatalError = createError(fatalError); |
| 10021 | fatalError.result = result; |
| 10022 | |
| 10023 | // Normalize error name. i.e. 'Unauthorized' -> 'unauthorized' (eg Sync Gateway) |
| 10024 | var errorName = (fatalError.name || '').toLowerCase(); |
| 10025 | if (errorName === 'unauthorized' || errorName === 'forbidden') { |
| 10026 | returnValue.emit('error', fatalError); |
| 10027 | returnValue.removeAllListeners(); |
| 10028 | } else { |
| 10029 | backOff(opts, returnValue, fatalError, function () { |
| 10030 | replicate(src, target, opts, returnValue); |
| 10031 | }); |
| 10032 | } |
| 10033 | } else { |
| 10034 | returnValue.emit('complete', result); |
| 10035 | returnValue.removeAllListeners(); |
| 10036 | } |
| 10037 | } |
| 10038 | |
| 10039 | function onChange(change, pending, lastSeq) { |
| 10040 | /* istanbul ignore if */ |
no test coverage detected
searching dependent graphs…