pave the way for more ux volflags

makes directory listings a tiny bit faster, about 7% or so
This commit is contained in:
ed 2024-11-22 22:24:56 +00:00
parent 2ab8924e2d
commit 0c43b592dc
5 changed files with 81 additions and 49 deletions

View file

@ -367,6 +367,8 @@ class VFS(object):
self.ahtml: dict[str, list[str]] = {}
self.aadmin: dict[str, list[str]] = {}
self.adot: dict[str, list[str]] = {}
self.js_ls = {}
self.js_htm = ""
if realpath:
rp = realpath + ("" if realpath.endswith(os.sep) else os.sep)
@ -2304,6 +2306,69 @@ class AuthSrv(object):
cur.close()
db.close()
self.js_ls = {}
self.js_htm = {}
for vn in self.vfs.all_nodes.values():
vf = vn.flags
vn.js_ls = {
"idx": "e2d" in vf,
"itag": "e2t" in vf,
"dnsort": "nsort" in vf,
"dsort": vf["sort"],
"dcrop": vf["crop"],
"dth3x": vf["th3x"],
"u2ts": vf["u2ts"],
"frand": bool(vf.get("rand")),
"lifetime": vf.get("lifetime") or 0,
"unlist": vf.get("unlist") or "",
}
js_htm = {
"s_name": self.args.bname,
"have_up2k_idx": "e2d" in vf,
"have_acode": not self.args.no_acode,
"have_shr": self.args.shr,
"have_zip": not self.args.no_zip,
"have_mv": not self.args.no_mv,
"have_del": not self.args.no_del,
"have_unpost": int(self.args.unpost),
"have_emp": self.args.emp,
"sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"),
"txt_ext": self.args.textfiles.replace(",", " "),
"def_hcols": list(vf.get("mth") or []),
"unlist0": vf.get("unlist") or "",
"dgrid": "grid" in vf,
"dgsel": "gsel" in vf,
"dnsort": "nsort" in vf,
"dsort": vf["sort"],
"dcrop": vf["crop"],
"dth3x": vf["th3x"],
"dvol": self.args.au_vol,
"idxh": int(self.args.ih),
"themes": self.args.themes,
"turbolvl": self.args.turbo,
"u2j": self.args.u2j,
"u2sz": self.args.u2sz,
"u2ts": vf["u2ts"],
"frand": bool(vf.get("rand")),
"lifetime": vn.js_ls["lifetime"],
"u2sort": self.args.u2sort,
}
vn.js_htm = json.dumps(js_htm)
vols = list(vfs.all_nodes.values())
if enshare:
assert shv # type: ignore # !rm
vols.append(shv)
vols.extend(list(shv.nodes.values()))
for vol in vols:
dbv = vol.get_dbv("")[0]
vol.js_ls = vol.js_ls or dbv.js_ls or {}
vol.js_htm = vol.js_htm or dbv.js_htm or "{}"
zs = str(vol.flags.get("tcolor") or self.args.tcolor)
vol.flags["tcolor"] = zs.lstrip("#")
def load_sessions(self, quiet=False) -> None:
# mutex me
if self.args.no_ses:

View file

@ -248,7 +248,6 @@ class HttpCli(object):
ka["ts"] = self.conn.hsrv.cachebuster()
ka["lang"] = self.args.lang
ka["favico"] = self.args.favico
ka["s_name"] = self.args.bname
ka["s_doctitle"] = self.args.doctitle
ka["tcolor"] = self.vn.flags["tcolor"]
@ -5496,63 +5495,28 @@ class HttpCli(object):
is_js = False
vf = vn.flags
unlist = vf.get("unlist", "")
ls_ret = {
"dirs": [],
"files": [],
"taglist": [],
"srvinf": srv_infot,
"acct": self.uname,
"idx": e2d,
"itag": e2t,
"dnsort": "nsort" in vf,
"dsort": vf["sort"],
"dcrop": vf["crop"],
"dth3x": vf["th3x"],
"u2ts": vf["u2ts"],
"lifetime": vn.flags.get("lifetime") or 0,
"frand": bool(vn.flags.get("rand")),
"unlist": unlist,
"perms": perms,
"cfg": vn.js_ls,
}
cgv = {
"ls0": None,
"acct": self.uname,
"perms": perms,
"u2ts": vf["u2ts"],
"lifetime": ls_ret["lifetime"],
"frand": bool(vn.flags.get("rand")),
"def_hcols": [],
"have_emp": self.args.emp,
"have_up2k_idx": e2d,
"have_acode": (not self.args.no_acode),
"have_mv": (not self.args.no_mv),
"have_del": (not self.args.no_del),
"have_zip": (not self.args.no_zip),
"have_shr": self.args.shr,
"have_unpost": int(self.args.unpost),
"sb_md": "" if "no_sb_md" in vf else (vf.get("md_sbf") or "y"),
"dgrid": "grid" in vf,
"dgsel": "gsel" in vf,
"dnsort": "nsort" in vf,
"dsort": vf["sort"],
"dcrop": vf["crop"],
"dth3x": vf["th3x"],
"dvol": self.args.au_vol,
"themes": self.args.themes,
"turbolvl": self.args.turbo,
"u2j": self.args.u2j,
"u2sz": self.args.u2sz,
"idxh": int(self.args.ih),
"u2sort": self.args.u2sort,
}
j2a = {
"cgv1": vn.js_htm,
"cgv": cgv,
"vpnodes": vpnodes,
"files": [],
"ls0": None,
"taglist": [],
"have_tags_idx": e2t,
"have_tags_idx": int(e2t),
"have_b_u": (self.can_write and self.uparam.get("b") == "u"),
"sb_lg": "" if "no_sb_lg" in vf else (vf.get("lg_sbf") or "y"),
"url_suf": url_suf,
@ -5924,17 +5888,12 @@ class HttpCli(object):
"dirs": dirs,
"files": files,
"taglist": taglist,
"unlist": unlist,
}
j2a["files"] = []
else:
j2a["files"] = dirs + files
j2a["taglist"] = taglist
j2a["txt_ext"] = self.args.textfiles.replace(",", " ")
if "mth" in vn.flags:
j2a["def_hcols"] = list(vn.flags["mth"])
if add_og and "raw" not in self.uparam:
j2a["this"] = self

View file

@ -132,16 +132,15 @@
<script>
var SR = {{ r|tojson }},
CGV1 = {{ cgv1 }},
CGV = {{ cgv|tojson }},
TS = "{{ ts }}",
dtheme = "{{ dtheme }}",
srvinf = "{{ srv_info }}",
s_name = "{{ s_name }}",
lang = "{{ lang }}",
dfavico = "{{ favico }}",
have_tags_idx = {{ have_tags_idx|tojson }},
have_tags_idx = {{ have_tags_idx }},
sb_lg = "{{ sb_lg }}",
txt_ext = "{{ txt_ext }}",
logues = {{ logues|tojson if sb_lg else "[]" }},
ls0 = {{ ls0|tojson }};

View file

@ -7518,6 +7518,7 @@ var treectl = (function () {
try {
var res = JSON.parse(this.responseText);
Object.assign(res, res.cfg);
}
catch (ex) {
if (r.ls_cb) {
@ -7784,6 +7785,7 @@ var treectl = (function () {
r.ls_cb = showfile.addlinks;
return r.reqls(get_evpath(), false, undefined, true);
}
ls0.unlist = unlist0;
var top = get_evpath();
if (r.chk_index_html(top, ls0))

View file

@ -5,10 +5,17 @@ if (!window.console || !console.log)
"log": function (msg) { }
};
if (!Object.prototype.assign)
Object.prototype.assign = function (a, b) {
for (var k in b)
a[k] = b[k];
};
if (window.CGV1)
Object.assign(window, window.CGV1);
if (window.CGV)
for (var k in CGV)
window[k] = CGV[k];
Object.assign(window, window.CGV);
var wah = '',