From fd7c71d6a3414db3ef247ed1d2a7aff0e6603b75 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 7 Jul 2025 14:15:58 +0000 Subject: [PATCH] add volflag to hide volume from controlpanel listing --- copyparty/__main__.py | 1 + copyparty/authsrv.py | 5 +++++ copyparty/cfg.py | 2 ++ copyparty/httpcli.py | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index aa6744d8..0ca8387b 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1535,6 +1535,7 @@ def add_ui(ap, retry): ap2.add_argument("--lg-sba", metavar="TXT", type=u, default="", help="the value of the iframe 'allow' attribute for prologue/epilogue docs (volflag=lg_sba); see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy#iframes") ap2.add_argument("--no-sb-md", action="store_true", help="don't sandbox README/PREADME.md documents (volflags: no_sb_md | sb_md)") ap2.add_argument("--no-sb-lg", action="store_true", help="don't sandbox prologue/epilogue docs (volflags: no_sb_lg | sb_lg); enables non-js support") + ap2.add_argument("--have-unlistc", action="store_true", help=argparse.SUPPRESS) def add_debug(ap): diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 0ad7b380..24bd4f07 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -2062,6 +2062,8 @@ class AuthSrv(object): elif self.args.re_maxage: vol.flags["scan"] = self.args.re_maxage + self.args.have_unlistc = False + all_mte = {} errors = False for vol in vfs.all_nodes.values(): @@ -2123,6 +2125,9 @@ class AuthSrv(object): if vol.flags.get("og"): self.args.uqe = True + if "unlistcr" in vol.flags or "unlistcw" in vol.flags: + self.args.have_unlistc = True + zs = str(vol.flags.get("tcolor", "")).lstrip("#") if len(zs) == 3: # fc5 => ffcc55 vol.flags["tcolor"] = "".join([x * 2 for x in zs]) diff --git a/copyparty/cfg.py b/copyparty/cfg.py index 01ab85c8..26505e8f 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -280,6 +280,8 @@ flagcats = { "nodirsz": "don't show total folder size", "robots": "allows indexing by search engines (default)", "norobots": "kindly asks search engines to leave", + "unlistcr": "don't list read-access in controlpanel", + "unlistcw": "don't list write-access in controlpanel", "no_sb_md": "disable js sandbox for markdown files", "no_sb_lg": "disable js sandbox for prologue/epilogue", "sb_md": "enable js sandbox for markdown files (default)", diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index f3d933fc..1a9ab91d 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -4949,6 +4949,11 @@ class HttpCli(object): fn = html_escape(fn) if fn else self.conn.hsrv.iiam dls.append((perc, hsent, spd, eta, idle, usr, erd, rds, fn)) + if self.args.have_unlistc: + allvols = self.asrv.vfs.all_vols + rvol = [x for x in rvol if "unlistcr" not in allvols[x[1:-1]].flags] + wvol = [x for x in wvol if "unlistcw" not in allvols[x[1:-1]].flags] + fmt = self.uparam.get("ls", "") if not fmt and (self.ua.startswith("curl/") or self.ua.startswith("fetch")): fmt = "v"