From 4e38e4087e9724b4d377e4401ca29dc1ddcee12c Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 28 Sep 2025 21:36:45 +0000 Subject: [PATCH] make warks (checksums) searchable --- README.md | 2 ++ copyparty/u2idx.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 3a327a06..7a835a75 100644 --- a/README.md +++ b/README.md @@ -869,6 +869,8 @@ the files will be hashed on the client-side, and each hash is sent to the server files go into `[ok]` if they exist (and you get a link to where it is), otherwise they land in `[ng]` * the main reason filesearch is combined with the uploader is cause the code was too spaghetti to separate it out somewhere else, this is no longer the case but now i've warmed up to the idea too much +if you have a "wark" (file-identifier/checksum) then you can also search for that in the [🔎] tab by putting `w = kFpDiztbZc8Z1Lzi` in the `raw` field + ### unpost diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 9696c3e2..bad6598d 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -196,6 +196,7 @@ class U2idx(object): is_key = True is_size = False is_date = False + is_wark = False field_end = "" # closing parenthesis or whatever kw_key = ["(", ")", "and ", "or ", "not "] kw_val = ["==", "=", "!=", ">", ">=", "<", "<=", "like "] @@ -214,6 +215,8 @@ class U2idx(object): is_key = kw in kw_key uq = uq[len(kw) :] ok = True + if is_wark: + kw = "= " q += kw break @@ -256,6 +259,10 @@ class U2idx(object): if icase: v = "casefold(%s)" % (v,) + elif v == "w": + v = "substr(up.w,1,16)" + is_wark = True + elif v == "tags" or ptn_mt.match(v): have_mt = True field_end = ") " @@ -296,6 +303,14 @@ class U2idx(object): is_size = False v = int(float(v) * 1024 * 1024) + if is_wark: + is_wark = False + v = v.strip("*") + if len(v) > 16: + v = v[:16] + if len(v) < 16: + raise Pebkac(400, "w/filehash must be 16+ chars") + else: if v.startswith("*"): head = "'%'||"