(changes)
| 10097 | |
| 10098 | |
| 10099 | function onChangesComplete(changes) { |
| 10100 | changesPending = false; |
| 10101 | /* istanbul ignore if */ |
| 10102 | if (returnValue.cancelled) { |
| 10103 | return completeReplication(); |
| 10104 | } |
| 10105 | |
| 10106 | // if no results were returned then we're done, |
| 10107 | // else fetch more |
| 10108 | if (changes.results.length > 0) { |
| 10109 | changesOpts.since = changes.results[changes.results.length - 1].seq; |
| 10110 | getChanges(); |
| 10111 | processPendingBatch(true); |
| 10112 | } else { |
| 10113 | |
| 10114 | var complete = function () { |
| 10115 | if (continuous) { |
| 10116 | changesOpts.live = true; |
| 10117 | getChanges(); |
| 10118 | } else { |
| 10119 | changesCompleted = true; |
| 10120 | } |
| 10121 | processPendingBatch(true); |
| 10122 | }; |
| 10123 | |
| 10124 | // update the checkpoint so we start from the right seq next time |
| 10125 | if (!currentBatch && changes.results.length === 0) { |
| 10126 | writingCheckpoint = true; |
| 10127 | checkpointer.writeCheckpoint(changes.last_seq, |
| 10128 | session).then(function () { |
| 10129 | writingCheckpoint = false; |
| 10130 | result.last_seq = last_seq = changes.last_seq; |
| 10131 | if (returnValue.cancelled) { |
| 10132 | completeReplication(); |
| 10133 | throw new Error('cancelled'); |
| 10134 | } else { |
| 10135 | complete(); |
| 10136 | } |
| 10137 | }) |
| 10138 | .catch(onCheckpointError); |
| 10139 | } else { |
| 10140 | complete(); |
| 10141 | } |
| 10142 | } |
| 10143 | } |
| 10144 | |
| 10145 | |
| 10146 | function onChangesError(err) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…