···220220 if limit < 1 or limit > 100:
221221 raise web.HTTPBadRequest(text="limit out of range")
222222 reverse = request.query.get("reverse") == "true"
223223- cursor = request.query.get("cursor", "")
224224- if not reverse and not cursor:
225225- cursor = "\xff" # compares greater than all valid rkeys
223223+ # note: "" compares less than all valid rkeys, "\xff" greater than.
224224+ cursor = request.query.get("cursor", "" if reverse else "\xff")
226225 did_or_handle = request.query["repo"]
227226 collection = request.query["collection"]
228227 records = []
+3-3
src/millipds/atproto_sync.py
···190190 limit = int(request.query.get("limit", 500))
191191 if limit < 1 or limit > 1000:
192192 raise web.HTTPBadRequest(text="limit out of range")
193193- cursor = int(request.query.get("cursor") or 0)
193193+ cursor = int(request.query.get("cursor", 0))
194194195195 cids = []
196196 for id_, cid in get_db(request).con.execute(
···246246 await ws.prepare(request) # TODO: should this be outside of try?
247247248248 last_sent_seq = None
249249- if cursor_str := request.query.get("cursor"):
249249+ if "cursor" in request.query:
250250 # TODO: try to limit number of concurrent backfillers? (it's more expensive than livetailing)
251251- cursor = int(cursor_str)
251251+ cursor = int(request.query["cursor"])
252252 db = get_db(request)
253253 while True:
254254 # we read one at a time to force gaps between reads - could be a perf win to read in small batches