make warks (checksums) searchable

This commit is contained in:
ed 2025-09-28 21:36:45 +00:00
parent f0ecb08347
commit 4e38e4087e
2 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -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 = "'%'||"