From 2529aa151d4f8982374dd6467f2c9e7c8d33c301 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 21 Oct 2023 12:11:49 +0000 Subject: [PATCH] tersen volume listing on startup --- copyparty/authsrv.py | 4 ++-- copyparty/cfg.py | 26 ++++++++++++++++++++++++-- copyparty/svchub.py | 5 +++++ copyparty/up2k.py | 20 ++++++++++++++++---- scripts/test/smoketest.py | 1 + 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index f3c1ca2f..58ade428 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1429,12 +1429,12 @@ class AuthSrv(object): for ga, vf in [["no_hash", "nohash"], ["no_idx", "noidx"]]: if vf in vol.flags: - ptn = vol.flags.pop(vf) + ptn = re.compile(vol.flags.pop(vf)) else: ptn = getattr(self.args, ga) if ptn: - vol.flags[vf] = re.compile(ptn) + vol.flags[vf] = ptn for ga, vf in vf_bmap().items(): if getattr(self.args, ga): diff --git a/copyparty/cfg.py b/copyparty/cfg.py index cc982bf6..9f73b9be 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -19,6 +19,9 @@ def vf_bmap() -> dict[str, str]: } for k in ( "dotsrch", + "e2d", + "e2ds", + "e2dsa", "e2t", "e2ts", "e2tsr", @@ -41,7 +44,12 @@ def vf_bmap() -> dict[str, str]: def vf_vmap() -> dict[str, str]: """argv-to-volflag: simple values""" - ret = {"th_convt": "convt", "th_size": "thsize"} + ret = { + "no_hash": "nohash", + "no_idx": "noidx", + "th_convt": "convt", + "th_size": "thsize", + } for k in ("dbd", "lg_sbf", "md_sbf", "nrand", "sort", "unlist", "u2ts"): ret[k] = k return ret @@ -50,7 +58,21 @@ def vf_vmap() -> dict[str, str]: def vf_cmap() -> dict[str, str]: """argv-to-volflag: complex/lists""" ret = {} - for k in ("html_head", "mte", "mth"): + for k in ( + "html_head", + "mte", + "mth", + "mtp", + "xad", + "xar", + "xau", + "xban", + "xbd", + "xbr", + "xbu", + "xiu", + "xm", + ): ret[k] = k return ret diff --git a/copyparty/svchub.py b/copyparty/svchub.py index 01d9df11..6ef6d37e 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -442,6 +442,11 @@ class SvcHub(object): mth = ODict.fromkeys(DEF_MTH.split(","), True) al.mth = odfusion(mth, al.mth) + for k in ["no_hash", "no_idx"]: + ptn = getattr(self.args, k) + if ptn: + setattr(self.args, k, re.compile(ptn)) + return True def _setlimits(self) -> None: diff --git a/copyparty/up2k.py b/copyparty/up2k.py index b600c2fa..23206049 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -24,7 +24,7 @@ from queue import Queue from .__init__ import ANYWIN, PY2, TYPE_CHECKING, WINDOWS from .authsrv import LEELOO_DALLAS, SSEELOG, VFS, AuthSrv from .bos import bos -from .cfg import vf_bmap, vf_vmap +from .cfg import vf_bmap, vf_cmap, vf_vmap from .fsutil import Fstab from .mtag import MParser, MTag from .util import ( @@ -796,13 +796,25 @@ class Up2k(object): fv = "\033[0;36m{}:\033[90m{}" fx = set(("html_head",)) fd = vf_bmap() + fd.update(vf_cmap()) fd.update(vf_vmap()) fd = {v: k for k, v in fd.items()} fl = { k: v for k, v in flags.items() - if k not in fd or v != getattr(self.args, fd[k]) + if k not in fd + or ( + v != getattr(self.args, fd[k]) + and str(v) != str(getattr(self.args, fd[k])) + ) } + for k1, k2 in vf_cmap().items(): + if k1 not in fl or k1 in fx: + continue + if str(fl[k1]) == str(getattr(self.args, k2)): + del fl[k1] + else: + fl[k1] = ",".join(x for x in fl) a = [ (ft if v is True else ff if v is False else fv).format(k, str(v)) for k, v in fl.items() @@ -821,7 +833,7 @@ class Up2k(object): vpath += "/" zs = " ".join(sorted(a)) - zs = zs.replace("30mre.compile(", "30m(") # nohash + zs = zs.replace("90mre.compile(", "90m(") # nohash self.log("/{} {}".format(vpath, zs), "35") reg = {} @@ -2130,7 +2142,7 @@ class Up2k(object): try: nfiles = next(cur.execute("select count(w) from up"))[0] - self.log("OK: {} |{}|".format(db_path, nfiles)) + self.log(" {} |{}|".format(db_path, nfiles), "90") return cur except: self.log("WARN: could not list files; DB corrupt?\n" + min_ex()) diff --git a/scripts/test/smoketest.py b/scripts/test/smoketest.py index 887e2201..95ebc40b 100644 --- a/scripts/test/smoketest.py +++ b/scripts/test/smoketest.py @@ -97,6 +97,7 @@ def tc1(vflags): ovid = f.read() args = [ + "-q", "-p4321", "-e2dsa", "-e2tsr",