diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index f784d080..8ef03c32 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1757,12 +1757,13 @@ class HttpCli(object): hits = idx.fsearch(vols, body) msg: Any = repr(hits) taglist: list[str] = [] + trunc = False else: # search by query params q = body["q"] n = body.get("n", self.args.srch_hits) self.log("qj: {} |{}|".format(q, n)) - hits, taglist = idx.search(vols, q, n) + hits, taglist, trunc = idx.search(vols, q, n) msg = len(hits) idx.p_end = time.time() @@ -1782,7 +1783,8 @@ class HttpCli(object): for hit in hits: hit["rp"] = self.args.RS + hit["rp"] - r = json.dumps({"hits": hits, "tag_order": order}).encode("utf-8") + rj = {"hits": hits, "tag_order": order, "trunc": trunc} + r = json.dumps(rj).encode("utf-8") self.reply(r, mime="application/json") return True diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 164b36be..d0ad50f0 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -120,10 +120,10 @@ class U2idx(object): def search( self, vols: list[tuple[str, str, dict[str, Any]]], uq: str, lim: int - ) -> tuple[list[dict[str, Any]], list[str]]: + ) -> tuple[list[dict[str, Any]], list[str], bool]: """search by query params""" if not HAVE_SQLITE3: - return [], [] + return [], [], False q = "" v: Union[str, int] = "" @@ -275,7 +275,7 @@ class U2idx(object): have_up: bool, have_mt: bool, lim: int, - ) -> tuple[list[dict[str, Any]], list[str]]: + ) -> tuple[list[dict[str, Any]], list[str], bool]: done_flag: list[bool] = [] self.active_id = "{:.6f}_{}".format( time.time(), threading.current_thread().ident @@ -316,9 +316,6 @@ class U2idx(object): c = cur.execute(uq, tuple(vuv)) for hit in c: w, ts, sz, rd, fn, ip, at = hit[:7] - lim -= 1 - if lim < 0: - break if rd.startswith("//") or fn.startswith("//"): rd, fn = s3dec(rd, fn) @@ -346,6 +343,10 @@ class U2idx(object): )[:fk] ) + lim -= 1 + if lim < 0: + break + seen_rps.add(rp) sret.append({"ts": int(ts), "sz": sz, "rp": rp + suf, "w": w[:16]}) @@ -368,7 +369,7 @@ class U2idx(object): ret.sort(key=itemgetter("rp")) - return ret, list(taglist.keys()) + return ret, list(taglist.keys()), lim < 0 def terminator(self, identifier: str, done_flag: list[bool]) -> None: for _ in range(self.timeout): diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index bd3f09da..6c26a68c 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -4875,7 +4875,7 @@ document.onkeydown = function (e) { var html = mk_files_header(tagord), seen = {}; html.push('
'); - html.push('