show filekeys in recent-uploads ui

This commit is contained in:
ed 2023-02-02 21:22:51 +00:00
parent 4a7633ab99
commit e67b695b23
3 changed files with 42 additions and 14 deletions

View file

@ -38,6 +38,8 @@ from .util import (
db_ex_chk,
djoin,
fsenc,
gen_filekey,
gen_filekey_dbg,
hidedir,
min_ex,
quotep,
@ -159,6 +161,7 @@ class Up2k(object):
Daemon(self._lastmodder, "up2k-lastmod")
self.fstab = Fstab(self.log_func)
self.gen_fk = self._gen_fk if self.args.log_fk else gen_filekey
if self.args.hash_mt < 2:
self.mth: Optional[MTHash] = None
@ -214,6 +217,9 @@ class Up2k(object):
self.log_func("up2k", msg, c)
def _gen_fk(self, salt: str, fspath: str, fsize: int, inode: int) -> str:
return gen_filekey_dbg(salt, fspath, fsize, inode, self.log, self.args.log_fk)
def _block(self, why: str) -> None:
self.blocked = why
self.log("uploads temporarily blocked due to " + why, 3)
@ -2257,7 +2263,7 @@ class Up2k(object):
purl = "{}/{}".format(job["vtop"], job["prel"]).strip("/")
purl = "/{}/".format(purl) if purl else "/"
return {
ret = {
"name": job["name"],
"purl": purl,
"size": job["size"],
@ -2267,6 +2273,18 @@ class Up2k(object):
"wark": wark,
}
if (
not ret["hash"]
and "fk" in vfs.flags
and (cj["user"] in vfs.axs.uread or cj["user"] in vfs.axs.upget)
):
ap = absreal(os.path.join(job["ptop"], job["prel"], job["name"]))
ino = 0 if ANYWIN else bos.stat(ap).st_ino
fk = self.gen_fk(self.args.fk_salt, ap, job["size"], ino)
ret["fk"] = fk[: vfs.flags["fk"]]
return ret
def _untaken(self, fdir: str, job: dict[str, Any], ts: float) -> str:
fname = job["name"]
ip = job["addr"]

View file

@ -959,16 +959,16 @@ ebi('op_up2k').innerHTML = (
' <tr>\n' +
' <td class="c" data-perm="read"><br />' + L.ul_par + '</td>\n' +
' <td class="c" rowspan="2">\n' +
' <input type="checkbox" id="u2rand" />\n' +
' <label for="u2rand" tt="' + L.ut_rand + '">🎲</label>\n' +
' <input type="checkbox" id="multitask" />\n' +
' <label for="multitask" tt="' + L.ut_mt + '">🏃</label>\n' +
' </td>\n' +
' <td class="c" rowspan="2">\n' +
' <input type="checkbox" id="potato" />\n' +
' <label for="potato" tt="' + L.ut_pot + '">🥔</label>\n' +
' </td>\n' +
' <td class="c" rowspan="2">\n' +
' <input type="checkbox" id="ask_up" />\n' +
' <label for="ask_up" tt="' + L.ut_ask + '">💭</label>\n' +
' <input type="checkbox" id="u2rand" />\n' +
' <label for="u2rand" tt="' + L.ut_rand + '">🎲</label>\n' +
' </td>\n' +
' <td class="c" data-perm="read" data-dep="idx" rowspan="2">\n' +
' <input type="checkbox" id="fsearch" />\n' +
@ -1077,7 +1077,7 @@ ebi('op_cfg').innerHTML = (
'<div>\n' +
' <h3>' + L.cl_uopts + '</h3>\n' +
' <div>\n' +
' <a id="multitask" class="tgl btn" href="#" tt="' + L.ut_mt + '">🏃</a>\n' +
' <a id="ask_up" class="tgl btn" href="#" tt="' + L.ut_ask + '">💭</a>\n' +
' <a id="hashw" class="tgl btn" href="#" tt="' + L.cut_mt + '">mt</a>\n' +
' <a id="u2turbo" class="tgl btn ttb" href="#" tt="' + L.cut_turbo + '">turbo</a>\n' +
' <a id="u2tdate" class="tgl btn ttb" href="#" tt="' + L.cut_datechk + '">date-chk</a>\n' +

View file

@ -1364,8 +1364,7 @@ function up2k_init(subtle) {
if (uc.fsearch)
entry.srch = 1;
if (uc.fsearch && uc.rand)
else if (uc.rand)
entry.rand = true;
if (biggest_file < entry.size)
@ -2217,13 +2216,24 @@ function up2k_init(subtle) {
t.sprs = response.sprs;
var rsp_purl = url_enc(response.purl);
if (rsp_purl !== t.purl || response.name !== t.name) {
// server renamed us (file exists / path restrictions)
console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + rsp_purl + "] [" + response.name + "]");
var fk = response.fk,
rsp_purl = url_enc(response.purl),
rename = rsp_purl !== t.purl || response.name !== t.name;
if (rename || fk) {
if (rename)
console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + rsp_purl + "] [" + response.name + "]");
t.purl = rsp_purl;
t.name = response.name;
pvis.seth(t.n, 0, linksplit(t.purl + uricom_enc(t.name)).join(' '));
var url = t.purl + uricom_enc(t.name);
if (fk) {
t.fk = fk;
url += '?k=' + fk;
}
pvis.seth(t.n, 0, linksplit(url).join(' '));
}
var chunksize = get_chunksize(t.size),
@ -2372,7 +2382,7 @@ function up2k_init(subtle) {
};
if (t.srch)
req.srch = 1;
if (t.rand)
else if (t.rand)
req.rand = true;
xhr.open('POST', t.purl, true);