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