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
This commit is contained in:
ed 2025-02-14 20:54:13 +00:00
parent 19520b2ec9
commit b190e676b4
3 changed files with 18 additions and 4 deletions

View file

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

View file

@ -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": {

View file

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