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]` 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 * 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 ### unpost

View file

@ -196,6 +196,7 @@ class U2idx(object):
is_key = True is_key = True
is_size = False is_size = False
is_date = False is_date = False
is_wark = False
field_end = "" # closing parenthesis or whatever field_end = "" # closing parenthesis or whatever
kw_key = ["(", ")", "and ", "or ", "not "] kw_key = ["(", ")", "and ", "or ", "not "]
kw_val = ["==", "=", "!=", ">", ">=", "<", "<=", "like "] kw_val = ["==", "=", "!=", ">", ">=", "<", "<=", "like "]
@ -214,6 +215,8 @@ class U2idx(object):
is_key = kw in kw_key is_key = kw in kw_key
uq = uq[len(kw) :] uq = uq[len(kw) :]
ok = True ok = True
if is_wark:
kw = "= "
q += kw q += kw
break break
@ -256,6 +259,10 @@ class U2idx(object):
if icase: if icase:
v = "casefold(%s)" % (v,) v = "casefold(%s)" % (v,)
elif v == "w":
v = "substr(up.w,1,16)"
is_wark = True
elif v == "tags" or ptn_mt.match(v): elif v == "tags" or ptn_mt.match(v):
have_mt = True have_mt = True
field_end = ") " field_end = ") "
@ -296,6 +303,14 @@ class U2idx(object):
is_size = False is_size = False
v = int(float(v) * 1024 * 1024) 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: else:
if v.startswith("*"): if v.startswith("*"):
head = "'%'||" head = "'%'||"