hide dotfiles from search results by default

This commit is contained in:
ed 2023-01-31 18:13:33 +00:00
parent 6d1d3e48d8
commit e413007eb0
5 changed files with 19 additions and 4 deletions

View file

@ -535,6 +535,8 @@ def get_sects():
\033[36mxlink$\033[35m cross-volume dupe detection / linking \033[36mxlink$\033[35m cross-volume dupe detection / linking
\033[36mxdev\033[35m do not descend into other filesystems \033[36mxdev\033[35m do not descend into other filesystems
\033[36mxvol\033[35m skip symlinks leaving the volume root \033[36mxvol\033[35m skip symlinks leaving the volume root
\033[36mdotsrch\033[35m show dotfiles in search results
\033[36mnodotsrch\033[35m hide dotfiles in search results (default)
\033[0mdatabase, audio tags: \033[0mdatabase, audio tags:
"mte", "mth", "mtp", "mtm" all work the same as -mte, -mth, ... "mte", "mth", "mtp", "mtm" all work the same as -mte, -mth, ...
@ -552,6 +554,12 @@ def get_sects():
\033[36mhtml_head=TXT\033[35m includes TXT in the <head> \033[36mhtml_head=TXT\033[35m includes TXT in the <head>
\033[36mrobots\033[35m allows indexing by search engines (default) \033[36mrobots\033[35m allows indexing by search engines (default)
\033[36mnorobots\033[35m kindly asks search engines to leave \033[36mnorobots\033[35m kindly asks search engines to leave
\033[36mno_sb_md\033[35m disable js sandbox for markdown files
\033[36mno_sb_lg\033[35m disable js sandbox for prologue/epilogue
\033[36msb_md\033[35m enable js sandbox for markdown files (default)
\033[36msb_lg\033[35m enable js sandbox for prologue/epilogue (default)
\033[36mmd_sbf\033[35m list of markdown-sandbox safeguards to disable
\033[36mlg_sbf\033[35m list of *logue-sandbox safeguards to disable
\033[0mothers: \033[0mothers:
\033[36mfk=8\033[35m generates per-file accesskeys, \033[36mfk=8\033[35m generates per-file accesskeys,
@ -944,6 +952,7 @@ def add_db_general(ap, hcores):
ap2.add_argument("--db-act", metavar="SEC", type=float, default=10, help="defer any scheduled volume reindexing until SEC seconds after last db write (uploads, renames, ...)") ap2.add_argument("--db-act", metavar="SEC", type=float, default=10, help="defer any scheduled volume reindexing until SEC seconds after last db write (uploads, renames, ...)")
ap2.add_argument("--srch-time", metavar="SEC", type=int, default=45, help="search deadline -- terminate searches running for more than SEC seconds") ap2.add_argument("--srch-time", metavar="SEC", type=int, default=45, help="search deadline -- terminate searches running for more than SEC seconds")
ap2.add_argument("--srch-hits", metavar="N", type=int, default=7999, help="max search results to allow clients to fetch; 125 results will be shown initially") ap2.add_argument("--srch-hits", metavar="N", type=int, default=7999, help="max search results to allow clients to fetch; 125 results will be shown initially")
ap2.add_argument("--dotsrch", action="store_true", help="show dotfiles in search results (volflags: dotsrch | nodotsrch)")
def add_db_metadata(ap): def add_db_metadata(ap):

View file

@ -1128,6 +1128,7 @@ class AuthSrv(object):
("no_dedup", "copydupes"), ("no_dedup", "copydupes"),
("magic", "magic"), ("magic", "magic"),
("xlink", "xlink"), ("xlink", "xlink"),
("dotsrch", "dotsrch"),
): ):
if getattr(self.args, ga): if getattr(self.args, ga):
vol.flags[vf] = True vol.flags[vf] = True
@ -1135,6 +1136,7 @@ class AuthSrv(object):
for ve, vd in ( for ve, vd in (
("sb_md", "no_sb_md"), ("sb_md", "no_sb_md"),
("sb_lg", "no_sb_lg"), ("sb_lg", "no_sb_lg"),
("nodotsrch", "dotsrch"),
): ):
if ve in vol.flags: if ve in vol.flags:
vol.flags.pop(vd, None) vol.flags.pop(vd, None)

View file

@ -3355,7 +3355,7 @@ class HttpCli(object):
if not self.args.no_readme and not logues[1]: if not self.args.no_readme and not logues[1]:
for fn in ["README.md", "readme.md"]: for fn in ["README.md", "readme.md"]:
fn = os.path.join(abspath, fn) fn = os.path.join(abspath, fn)
if bos.path.exists(fn): if bos.path.isfile(fn):
with open(fsenc(fn), "rb") as f: with open(fsenc(fn), "rb") as f:
readme = f.read().decode("utf-8") readme = f.read().decode("utf-8")
break break

View file

@ -311,6 +311,7 @@ class U2idx(object):
sret = [] sret = []
fk = flags.get("fk") fk = flags.get("fk")
dots = flags.get("dotsrch")
c = cur.execute(uq, tuple(vuv)) c = cur.execute(uq, tuple(vuv))
for hit in c: for hit in c:
w, ts, sz, rd, fn, ip, at = hit[:7] w, ts, sz, rd, fn, ip, at = hit[:7]
@ -321,6 +322,10 @@ class U2idx(object):
if rd.startswith("//") or fn.startswith("//"): if rd.startswith("//") or fn.startswith("//"):
rd, fn = s3dec(rd, fn) rd, fn = s3dec(rd, fn)
rp = quotep("/".join([x for x in [vtop, rd, fn] if x]))
if not dots and "/." in ("/" + rp):
continue
if not fk: if not fk:
suf = "" suf = ""
else: else:
@ -337,8 +342,7 @@ class U2idx(object):
)[:fk] )[:fk]
) )
rp = quotep("/".join([x for x in [vtop, rd, fn] if x])) + suf sret.append({"ts": int(ts), "sz": sz, "rp": rp + suf, "w": w[:16]})
sret.append({"ts": int(ts), "sz": sz, "rp": rp, "w": w[:16]})
for hit in sret: for hit in sret:
w = hit["w"] w = hit["w"]

View file

@ -98,7 +98,7 @@ class Cfg(Namespace):
def __init__(self, a=None, v=None, c=None): def __init__(self, a=None, v=None, c=None):
ka = {} ka = {}
ex = "daw dav_inf dav_mac e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod hardlink ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nw xdev xlink xvol" ex = "daw dav_inf dav_mac dotsrch e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod hardlink ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nw xdev xlink xvol"
ka.update(**{k: False for k in ex.split()}) ka.update(**{k: False for k in ex.split()})
ex = "dotpart no_rescan no_sendfile no_voldump plain_ip" ex = "dotpart no_rescan no_sendfile no_voldump plain_ip"