diff --git a/copyparty/__main__.py b/copyparty/__main__.py index af0df4af..435bfcc2 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1905,6 +1905,7 @@ def add_txt(ap): ap2.add_argument("--rw-edit", metavar="T,T", type=u, default="md", help="comma-sep. list of file-extensions to allow editing with permissions read+write; all others require read+write+delete (volflag=rw_edit)") ap2.add_argument("--md-no-br", action="store_true", help="markdown: disable newline-is-newline; will only render a newline into the html given two trailing spaces or a double-newline (volflag=md_no_br)") ap2.add_argument("--md-hist", metavar="TXT", type=u, default="s", help="where to store old version of markdown files; [\033[32ms\033[0m]=subfolder, [\033[32mv\033[0m]=volume-histpath, [\033[32mn\033[0m]=nope/disabled (volflag=md_hist)") + ap2.add_argument("--show-hist", action="store_true", help="allow browsing the .hist folder; enable to view old markdown files (volflag=show_hist)") ap2.add_argument("--txt-eol", metavar="TYPE", type=u, default="", help="enable EOL conversion when writing documents; supported: CRLF, LF (volflag=txt_eol)") ap2.add_argument("-mcr", metavar="SEC", type=int, default=60, help="the textfile editor will check for serverside changes every \033[33mSEC\033[0m seconds") ap2.add_argument("-emp", action="store_true", help="enable markdown plugins -- neat but dangerous, big XSS risk") diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 08c39335..92132578 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -2802,6 +2802,13 @@ class AuthSrv(object): zs = "select %s from up where rd=? and fn=?" % (", ".join(up_q),) vol.flags["ls_q_m"] = (zs if up_m else "", up_m) + for tab in (rhisttab, rdbpaths): + for ap, vn in tab.items(): + if "show_hist" not in vn.flags and ( + ap == os.path.join(vn.realpath, ".hist") + ): + vn.add("", ".hist", ".hist") + vfs.all_fvols = { zs: vol for zs, vol in vfs.all_vols.items() if "is_file" in vol.flags } diff --git a/copyparty/cfg.py b/copyparty/cfg.py index b519f645..c4cb5f0b 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -65,6 +65,7 @@ def vf_bmap() -> dict[str, str]: "rm_partial", "rmagic", "rss", + "show_hist", "ui_noacci", "ui_nocpla", "ui_nolbar", @@ -407,6 +408,7 @@ flagcats = { "rw_edit=md,txt": "only require read+write to edit .md and .txt", "md_no_br": "newline only on double-newline or two tailing spaces", "md_hist": "where to put markdown backups; s=subfolder, v=volHist, n=nope", + "show_hist": "allow browsing the .hist folder (old textfiles)", "exp": "enable textfile expansion; see --help-exp", "exp_md": "placeholders to expand in markdown files; see --help", "exp_lg": "placeholders to expand in prologue/epilogue; see --help", diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 9e50fd97..711cf8dc 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -7162,7 +7162,7 @@ class HttpCli(object): # [num-backups, most-recent, hist-path] hist: dict[str, tuple[int, float, str]] = {} try: - if vf["md_hist"] != "s": + if "show_hist" not in vf or vf["md_hist"] != "s": raise Exception() histdir = os.path.join(fsroot, ".hist") ptn = RE_MDV diff --git a/tests/util.py b/tests/util.py index f9955f24..d50ab383 100644 --- a/tests/util.py +++ b/tests/util.py @@ -145,7 +145,7 @@ class Cfg(Namespace): def __init__(self, a=None, v=None, c=None, **ka0): ka = {} - ex = "allow_flac allow_wav chpw cookie_lax daw dav_auth dav_mac dav_rt dlni dothidden e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only http_no_tcp ih ihead localtime log_badxml magic md_no_br nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_dupe_m no_fnugg no_html no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_script no_tail no_tarcmp no_thumb no_vthumb no_u2abrt no_zip no_zls nrand nsort nw og og_no_head og_s_title ohead opds q rand re_dirsz reflink rm_partial rmagic rss smb srch_dbg srch_excl srch_icase stats ui_noacci ui_nocpla ui_noctxb ui_nolbar ui_nombar ui_nonav ui_notree ui_norepl ui_nosrvi uqe usernames vague_403 vc ver vol_nospawn vol_or_crash wo_up_readme write_uplog xdev xlink xvol zipmaxu zs" + ex = "allow_flac allow_wav chpw cookie_lax daw dav_auth dav_mac dav_rt dlni dothidden e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only http_no_tcp ih ihead localtime log_badxml magic md_no_br nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_dupe_m no_fnugg no_html no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_script no_tail no_tarcmp no_thumb no_vthumb no_u2abrt no_zip no_zls nrand nsort nw og og_no_head og_s_title ohead opds q rand re_dirsz reflink rm_partial rmagic rss show_hist smb srch_dbg srch_excl srch_icase stats ui_noacci ui_nocpla ui_noctxb ui_nolbar ui_nombar ui_nonav ui_notree ui_norepl ui_nosrvi uqe usernames vague_403 vc ver vol_nospawn vol_or_crash 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 wram re_dhash see_dots plain_ip"