mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
show filekeys in recent-uploads ui
This commit is contained in:
parent
4a7633ab99
commit
e67b695b23
|
@ -38,6 +38,8 @@ from .util import (
|
||||||
db_ex_chk,
|
db_ex_chk,
|
||||||
djoin,
|
djoin,
|
||||||
fsenc,
|
fsenc,
|
||||||
|
gen_filekey,
|
||||||
|
gen_filekey_dbg,
|
||||||
hidedir,
|
hidedir,
|
||||||
min_ex,
|
min_ex,
|
||||||
quotep,
|
quotep,
|
||||||
|
@ -159,6 +161,7 @@ class Up2k(object):
|
||||||
Daemon(self._lastmodder, "up2k-lastmod")
|
Daemon(self._lastmodder, "up2k-lastmod")
|
||||||
|
|
||||||
self.fstab = Fstab(self.log_func)
|
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:
|
if self.args.hash_mt < 2:
|
||||||
self.mth: Optional[MTHash] = None
|
self.mth: Optional[MTHash] = None
|
||||||
|
@ -214,6 +217,9 @@ class Up2k(object):
|
||||||
|
|
||||||
self.log_func("up2k", msg, c)
|
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:
|
def _block(self, why: str) -> None:
|
||||||
self.blocked = why
|
self.blocked = why
|
||||||
self.log("uploads temporarily blocked due to " + why, 3)
|
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(job["vtop"], job["prel"]).strip("/")
|
||||||
purl = "/{}/".format(purl) if purl else "/"
|
purl = "/{}/".format(purl) if purl else "/"
|
||||||
|
|
||||||
return {
|
ret = {
|
||||||
"name": job["name"],
|
"name": job["name"],
|
||||||
"purl": purl,
|
"purl": purl,
|
||||||
"size": job["size"],
|
"size": job["size"],
|
||||||
|
@ -2267,6 +2273,18 @@ class Up2k(object):
|
||||||
"wark": wark,
|
"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:
|
def _untaken(self, fdir: str, job: dict[str, Any], ts: float) -> str:
|
||||||
fname = job["name"]
|
fname = job["name"]
|
||||||
ip = job["addr"]
|
ip = job["addr"]
|
||||||
|
|
|
@ -959,16 +959,16 @@ ebi('op_up2k').innerHTML = (
|
||||||
' <tr>\n' +
|
' <tr>\n' +
|
||||||
' <td class="c" data-perm="read"><br />' + L.ul_par + '</td>\n' +
|
' <td class="c" data-perm="read"><br />' + L.ul_par + '</td>\n' +
|
||||||
' <td class="c" rowspan="2">\n' +
|
' <td class="c" rowspan="2">\n' +
|
||||||
' <input type="checkbox" id="u2rand" />\n' +
|
' <input type="checkbox" id="multitask" />\n' +
|
||||||
' <label for="u2rand" tt="' + L.ut_rand + '">🎲</label>\n' +
|
' <label for="multitask" tt="' + L.ut_mt + '">🏃</label>\n' +
|
||||||
' </td>\n' +
|
' </td>\n' +
|
||||||
' <td class="c" rowspan="2">\n' +
|
' <td class="c" rowspan="2">\n' +
|
||||||
' <input type="checkbox" id="potato" />\n' +
|
' <input type="checkbox" id="potato" />\n' +
|
||||||
' <label for="potato" tt="' + L.ut_pot + '">🥔</label>\n' +
|
' <label for="potato" tt="' + L.ut_pot + '">🥔</label>\n' +
|
||||||
' </td>\n' +
|
' </td>\n' +
|
||||||
' <td class="c" rowspan="2">\n' +
|
' <td class="c" rowspan="2">\n' +
|
||||||
' <input type="checkbox" id="ask_up" />\n' +
|
' <input type="checkbox" id="u2rand" />\n' +
|
||||||
' <label for="ask_up" tt="' + L.ut_ask + '">💭</label>\n' +
|
' <label for="u2rand" tt="' + L.ut_rand + '">🎲</label>\n' +
|
||||||
' </td>\n' +
|
' </td>\n' +
|
||||||
' <td class="c" data-perm="read" data-dep="idx" rowspan="2">\n' +
|
' <td class="c" data-perm="read" data-dep="idx" rowspan="2">\n' +
|
||||||
' <input type="checkbox" id="fsearch" />\n' +
|
' <input type="checkbox" id="fsearch" />\n' +
|
||||||
|
@ -1077,7 +1077,7 @@ ebi('op_cfg').innerHTML = (
|
||||||
'<div>\n' +
|
'<div>\n' +
|
||||||
' <h3>' + L.cl_uopts + '</h3>\n' +
|
' <h3>' + L.cl_uopts + '</h3>\n' +
|
||||||
' <div>\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="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="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' +
|
' <a id="u2tdate" class="tgl btn ttb" href="#" tt="' + L.cut_datechk + '">date-chk</a>\n' +
|
||||||
|
|
|
@ -1364,8 +1364,7 @@ function up2k_init(subtle) {
|
||||||
|
|
||||||
if (uc.fsearch)
|
if (uc.fsearch)
|
||||||
entry.srch = 1;
|
entry.srch = 1;
|
||||||
|
else if (uc.rand)
|
||||||
if (uc.fsearch && uc.rand)
|
|
||||||
entry.rand = true;
|
entry.rand = true;
|
||||||
|
|
||||||
if (biggest_file < entry.size)
|
if (biggest_file < entry.size)
|
||||||
|
@ -2217,13 +2216,24 @@ function up2k_init(subtle) {
|
||||||
|
|
||||||
t.sprs = response.sprs;
|
t.sprs = response.sprs;
|
||||||
|
|
||||||
var rsp_purl = url_enc(response.purl);
|
var fk = response.fk,
|
||||||
if (rsp_purl !== t.purl || response.name !== t.name) {
|
rsp_purl = url_enc(response.purl),
|
||||||
// server renamed us (file exists / path restrictions)
|
rename = rsp_purl !== t.purl || response.name !== t.name;
|
||||||
console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + rsp_purl + "] [" + response.name + "]");
|
|
||||||
|
if (rename || fk) {
|
||||||
|
if (rename)
|
||||||
|
console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + rsp_purl + "] [" + response.name + "]");
|
||||||
|
|
||||||
t.purl = rsp_purl;
|
t.purl = rsp_purl;
|
||||||
t.name = response.name;
|
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),
|
var chunksize = get_chunksize(t.size),
|
||||||
|
@ -2372,7 +2382,7 @@ function up2k_init(subtle) {
|
||||||
};
|
};
|
||||||
if (t.srch)
|
if (t.srch)
|
||||||
req.srch = 1;
|
req.srch = 1;
|
||||||
if (t.rand)
|
else if (t.rand)
|
||||||
req.rand = true;
|
req.rand = true;
|
||||||
|
|
||||||
xhr.open('POST', t.purl, true);
|
xhr.open('POST', t.purl, true);
|
||||||
|
|
Loading…
Reference in a new issue