From b190e676b4d6c3f2027b0e58c2d98af209c710cb Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 14 Feb 2025 20:54:13 +0000 Subject: [PATCH] fix cosmetic volflag stuff: * `xz` would show the "unrecognized volflag" warning, but it still applied correctly * removing volflags with `-foo` would also show the warning but it would still get removed correctly * hide `ext_th_d` in the startup volume-listing --- copyparty/authsrv.py | 17 +++++++++++++++-- copyparty/cfg.py | 3 ++- copyparty/up2k.py | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 085a805f..6ccaafe7 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1389,8 +1389,16 @@ class AuthSrv(object): name = name.lower() # volflags are snake_case, but a leading dash is the removal operator - if name not in flagdescs and "-" in name[1:]: - name = name[:1] + name[1:].replace("-", "_") + stripped = name.lstrip("-") + zi = len(name) - len(stripped) + if zi > 1: + t = "WARNING: the config for volume [/%s] specified a volflag with multiple leading hyphens (%s); use one hyphen to remove, or zero hyphens to add a flag. Will now enable flag [%s]" + self.log(t % (vpath, name, stripped), 3) + name = stripped + zi = 0 + + if stripped not in flagdescs and "-" in stripped: + name = ("-" * zi) + stripped.replace("-", "_") desc = flagdescs.get(name.lstrip("-"), "?").replace("\n", " ") @@ -1576,6 +1584,11 @@ class AuthSrv(object): for vol in vfs.all_vols.values(): unknown_flags = set() for k, v in vol.flags.items(): + stripped = k.lstrip("-") + if k != stripped and stripped not in vol.flags: + t = "WARNING: the config for volume [/%s] tried to remove volflag [%s] by specifying [%s] but that volflag was not already set" + self.log(t % (vol.vpath, stripped, k), 3) + k = stripped if k not in flagdescs and k not in k_ign: unknown_flags.add(k) if unknown_flags: diff --git a/copyparty/cfg.py b/copyparty/cfg.py index 224f1955..fbf053dc 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -156,7 +156,8 @@ flagcats = { "daw": "enable full WebDAV write support (dangerous);\nPUT-operations will now \033[1;31mOVERWRITE\033[0;35m existing files", "nosub": "forces all uploads into the top folder of the vfs", "magic": "enables filetype detection for nameless uploads", - "gz": "allows server-side gzip of uploads with ?gz (also c,xz)", + "gz": "allows server-side gzip compression of uploads with ?gz", + "xz": "allows server-side lzma compression of uploads with ?xz", "pk": "forces server-side compression, optional arg: xz,9", }, "upload rules": { diff --git a/copyparty/up2k.py b/copyparty/up2k.py index d690de67..f8e20842 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -1081,7 +1081,7 @@ class Up2k(object): ft = "\033[0;32m{}{:.0}" ff = "\033[0;35m{}{:.0}" fv = "\033[0;36m{}:\033[90m{}" - zs = "html_head mv_re_r mv_re_t rm_re_r rm_re_t srch_re_dots srch_re_nodot" + zs = "ext_th_d html_head mv_re_r mv_re_t rm_re_r rm_re_t srch_re_dots srch_re_nodot" fx = set(zs.split()) fd = vf_bmap() fd.update(vf_cmap())