From c599e2aaa386ffae9b4fdb6e72d90b5839e37e8e Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 8 Jun 2025 18:32:32 +0200 Subject: [PATCH] add opt for dotfile visibility default --- README.md | 2 ++ copyparty/__main__.py | 1 + copyparty/authsrv.py | 1 + copyparty/web/browser.js | 2 +- tests/util.py | 2 +- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14127da1..2ddbb93a 100644 --- a/README.md +++ b/README.md @@ -561,6 +561,8 @@ a client can request to see dotfiles in directory listings if global option `-ed dotfiles do not appear in search results unless one of the above is true, **and** the global option / volflag `dotsrch` is set +> even if user has permission to see dotfiles, they are default-hidden unless `--see-dots` is set, and/or user has enabled the `dotfiles` option in the settings tab + config file example, where the same permission to see dotfiles is given in two different ways just for reference: ```yaml diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 8f67f282..f346bc5f 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1494,6 +1494,7 @@ def add_ui(ap, retry): ap2.add_argument("--sort", metavar="C,C,C", type=u, default="href", help="default sort order, comma-separated column IDs (see header tooltips), prefix with '-' for descending. Examples: \033[32mhref -href ext sz ts tags/Album tags/.tn\033[0m (volflag=sort)") ap2.add_argument("--nsort", action="store_true", help="default-enable natural sort of filenames with leading numbers (volflag=nsort)") ap2.add_argument("--hsortn", metavar="N", type=int, default=2, help="number of sorting rules to include in media URLs by default (volflag=hsortn)") + ap2.add_argument("--see-dots", action="store_true", help="default-enable seeing dotfiles; only takes effect if user has the necessary permissions") ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching \033[33mREGEX\033[0m in file list. Purely cosmetic! Does not affect API calls, just the browser. Example: [\033[32m\\.(js|css)$\033[0m] (volflag=unlist)") ap2.add_argument("--favico", metavar="TXT", type=u, default="c 000 none" if retry else "🎉 000 none", help="\033[33mfavicon-text\033[0m [ \033[33mforeground\033[0m [ \033[33mbackground\033[0m ] ], set blank to disable") ap2.add_argument("--ext-th", metavar="E=VP", type=u, action="append", help="use thumbnail-image \033[33mVP\033[0m for file-extension \033[33mE\033[0m, example: [\033[32mexe=/.res/exe.png\033[0m] (volflag=ext_th)") diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 98e05631..d25714c2 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -2579,6 +2579,7 @@ class AuthSrv(object): "txt_ext": self.args.textfiles.replace(",", " "), "def_hcols": list(vf.get("mth") or []), "unlist0": vf.get("unlist") or "", + "see_dots": self.args.see_dots, "dgrid": "grid" in vf, "dgsel": "gsel" in vf, "dnsort": "nsort" in vf, diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 2df78141..ff85a1cc 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -7504,7 +7504,7 @@ var treectl = (function () { bcfg_bind(r, 'idxh', 'idxh', idxh, setidxh); bcfg_bind(r, 'dyn', 'dyntree', true, onresize); bcfg_bind(r, 'csel', 'csel', dgsel); - bcfg_bind(r, 'dots', 'dotfiles', false, function (v) { + bcfg_bind(r, 'dots', 'dotfiles', see_dots, function (v) { r.goto(); var xhr = new XHR(); xhr.open('GET', SR + '/?setck=dots=' + (v ? 'y' : ''), true); diff --git a/tests/util.py b/tests/util.py index 891036e5..f938aa55 100644 --- a/tests/util.py +++ b/tests/util.py @@ -146,7 +146,7 @@ class Cfg(Namespace): ex = "chpw daw dav_auth dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink ih ihead magic hardlink_only nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_tarcmp no_thumb no_vthumb no_zip nrand nsort nw og og_no_head og_s_title ohead q rand re_dirsz rss smb srch_dbg srch_excl stats uqe vague_403 vc ver wo_up_readme write_uplog xdev xlink xvol zipmaxu zs" ka.update(**{k: False for k in ex.split()}) - ex = "dav_inf dedup dotpart dotsrch hook_v no_dhash no_fastboot no_fpool no_htp no_rescan no_sendfile no_ses no_snap no_up_list no_voldump re_dhash plain_ip" + ex = "dav_inf dedup dotpart dotsrch hook_v no_dhash no_fastboot no_fpool no_htp no_rescan no_sendfile no_ses no_snap no_up_list no_voldump re_dhash see_dots plain_ip" ka.update(**{k: True for k in ex.split()}) ex = "ah_cli ah_gen css_browser dbpath hist ipu js_browser js_other mime mimes no_forget no_hash no_idx nonsus_urls og_tpl og_ua ua_nodoc ua_nozip"