Commit 60e61c2611fbf8281189ddd6fb823719a67a97e2
fix roots query looping when less than limit results
Matt McKegg committed on 6/28/2017, 9:10:05 AMParent: a6aab6f1d2a86e5cf04121dbc040f657ecdca01f
Files changed
sbot/roots.js | changed |
sbot/roots.js | ||
---|---|---|
@@ -149,17 +149,26 @@ | ||
149 | 149 | ) |
150 | 150 | |
151 | 151 | // TRUNCATE |
152 | 152 | if (typeof limit === 'number') { |
153 | + var count = 0 | |
153 | 154 | return pullCat([ |
154 | 155 | pull( |
155 | 156 | stream, |
156 | - pull.take(limit) | |
157 | + pull.take(limit), | |
158 | + pull.through(() => { | |
159 | + count += 1 | |
160 | + }) | |
157 | 161 | ), |
158 | 162 | |
159 | 163 | // send truncated marker for resuming search |
160 | - pull.values([marker]) | |
164 | + pull( | |
165 | + pull.values([marker]), | |
166 | + pull.filter(() => count === limit) | |
167 | + ) | |
161 | 168 | ]) |
169 | + } else { | |
170 | + return stream | |
162 | 171 | } |
163 | 172 | } |
164 | 173 | } |
165 | 174 |
Built with git-ssb-web