diff --git a/README.md b/README.md index 618602fd..f4ad79fc 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,9 @@ small collection of user feedback * Windows: msys2-python 3.8.6 occasionally throws `RuntimeError: release unlocked lock` when leaving a scoped mutex in up2k * this is an msys2 bug, the regular windows edition of python is fine +* VirtualBox: sqlite throws `Disk I/O Error` when running in a VM and the up2k database is in a vboxsf + * use `--hist` or the `hist` volflag (`-v [...]:chist=/tmp/foo`) to place the db inside the vm instead + # the browser diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 2a495037..e6f404df 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -7,6 +7,7 @@ import time import threading from datetime import datetime +from .__init__ import unicode from .util import s3dec, Pebkac, min_ex from .up2k import up2k_wark_from_hashlist @@ -90,6 +91,8 @@ class U2idx(object): mt_ctr = 0 mt_keycmp = "substr(up.w,1,16)" mt_keycmp2 = None + ptn_lc = re.compile(r" (mt[0-9]+\.v) ([=]+) \? $") + ptn_lcv = re.compile(r"[a-zA-Z]") while True: uq = uq.strip() @@ -182,6 +185,21 @@ class U2idx(object): va.append(v) is_key = True + # lowercase tag searches + m = ptn_lc.search(q) + if not m or not ptn_lcv.search(unicode(v)): + continue + + va.pop() + va.append(v.lower()) + q = q[: m.start()] + + field, oper = m.groups() + if oper in ["=", "=="]: + q += " {} like ? ".format(field) + else: + q += " lower({}) {} ? ".format(field, oper) + try: return self.run_query(vols, joins + "where " + q, va) except Exception as ex: diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 788c1437..415f96a3 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -596,7 +596,7 @@ class Up2k(object): c2 = conn.cursor() c3 = conn.cursor() n_left = cur.execute("select count(w) from up").fetchone()[0] - for w, rd, fn in cur.execute("select w, rd, fn from up"): + for w, rd, fn in cur.execute("select w, rd, fn from up order by rd, fn"): n_left -= 1 q = "select w from mt where w = ?" if c2.execute(q, (w[:16],)).fetchone(): @@ -1512,7 +1512,7 @@ def up2k_chunksize(filesize): def up2k_wark_from_hashlist(salt, filesize, hashes): - """ server-reproducible file identifier, independent of name or location """ + """server-reproducible file identifier, independent of name or location""" ident = [salt, str(filesize)] ident.extend(hashes) ident = "\n".join(ident)