This commit is contained in:
ed 2021-02-20 17:39:08 +01:00
parent fda98730ac
commit 4f8cf2fc87
8 changed files with 51 additions and 32 deletions

View file

@ -311,7 +311,7 @@ class HttpCli(object):
reader, _ = self.get_body_reader()
for buf in reader:
buf = buf.decode("utf-8", "replace")
self.log("urlform:\n {}\n".format(buf))
self.log("urlform @ {}\n {}\n".format(self.vpath, buf))
if "get" in opt:
return self.handle_get()

View file

@ -412,11 +412,11 @@ class Up2k(object):
if job["need"]:
self.log("unfinished:\n {0}\n {1}".format(src, dst))
err = "partial upload exists at a different location; please resume uploading here instead:\n"
err += vsrc + " "
err += "/" + vsrc + " "
raise Pebkac(400, err)
elif "nodupe" in job["flag"]:
self.log("dupe-reject:\n {0}\n {1}".format(src, dst))
err = "upload rejected, file already exists:\n " + vsrc + " "
err = "upload rejected, file already exists:\n/" + vsrc + " "
raise Pebkac(400, err)
else:
# symlink to the client-provided name,
@ -644,14 +644,14 @@ class Up2k(object):
while not self.lastmod_q.empty():
ready.append(self.lastmod_q.get())
# self.log("lmod", "got {}".format(len(ready)))
# self.log("lmod: got {}".format(len(ready)))
time.sleep(5)
for path, times in ready:
self.log("lmod", "setting times {} on {}".format(times, path))
self.log("lmod: setting times {} on {}".format(times, path))
try:
os.utime(fsenc(path), times)
except:
self.log("lmod", "failed to utime ({}, {})".format(path, times))
self.log("lmod: failed to utime ({}, {})".format(path, times))
def _snapshot(self):
persist_interval = 30 # persist unfinished uploads index every 30 sec

View file

@ -154,10 +154,12 @@ a,
#srv_info span {
color: #fff;
}
a.play {
#files tbody a.play {
color: #e70;
padding: .2em;
margin: -.2em;
}
a.play.act {
#files tbody a.play.act {
color: #af0;
}
#blocked {
@ -423,6 +425,8 @@ input[type="checkbox"]:checked+label {
#detree {
padding: .3em .5em;
font-size: 1.5em;
display: inline-block;
width: 100%;
}
#treefiles #files tbody {
border-radius: 0 .7em 0 .7em;

View file

@ -928,7 +928,7 @@ function autoplay_blocked() {
})();
function reload_browser() {
function reload_browser(not_mp) {
makeSortable(ebi('files'));
var parts = get_vpath().split('/');
@ -945,10 +945,21 @@ function reload_browser() {
ebi('path').appendChild(o);
}
if (mp && mp.au) {
mp.au.pause();
mp.au = null;
var oo = document.querySelectorAll('#files>tbody>tr>td:nth-child(3)');
for (var a = 0, aa = oo.length; a < aa; a++) {
var sz = oo[a].textContent.replace(/ /g, ""),
hsz = sz.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
oo[a].textContent = hsz;
}
if (!not_mp) {
if (mp && mp.au) {
mp.au.pause();
mp.au = null;
}
widget.close();
mp = init_mp();
}
widget.close();
mp = init_mp();
}
reload_browser(true);

View file

@ -151,10 +151,6 @@ function up2k_init(have_crypto) {
ebi('u2notbtn').innerHTML = '';
}
var post_url = ebi('op_bup').getElementsByTagName('form')[0].getAttribute('action');
if (post_url && post_url.charAt(post_url.length - 1) !== '/')
post_url += '/';
var shame = 'your browser <a href="https://www.chromium.org/blink/webcrypto">disables sha512</a> unless you <a href="' + (window.location + '').replace(':', 's:') + '">use https</a>'
var is_https = (window.location + '').indexOf('https:') === 0;
if (is_https)
@ -371,6 +367,7 @@ function up2k_init(have_crypto) {
"name": fobj.name,
"size": fobj.size,
"lmod": lmod / 1000,
"purl": get_vpath(),
"hash": []
};
@ -385,7 +382,7 @@ function up2k_init(have_crypto) {
var tr = document.createElement('tr');
tr.innerHTML = '<td id="f{0}n"></td><td id="f{0}t">hashing</td><td id="f{0}p" class="prog"></td>'.format(st.files.length);
tr.getElementsByTagName('td')[0].textContent = entry.name;
tr.getElementsByTagName('td')[0].innerHTML = linksplit(esc(entry.purl + entry.name)).join(' ');
ebi('u2tab').appendChild(tr);
st.files.push(entry);
@ -758,8 +755,7 @@ function up2k_init(have_crypto) {
else {
smsg = 'found';
var hit = response[0],
links = linksplit(hit.rp),
msg = links.join(''),
msg = linksplit(hit.rp).join(''),
tr = new Date(hit.ts * 1000).toISOString().replace("T", " ").slice(0, -5),
tu = new Date(t.lmod * 1000).toISOString().replace("T", " ").slice(0, -5),
diff = parseInt(t.lmod) - parseInt(hit.ts),
@ -779,7 +775,7 @@ function up2k_init(have_crypto) {
if (response.name !== t.name) {
// file exists; server renamed us
t.name = response.name;
ebi('f{0}n'.format(t.n)).textContent = t.name;
ebi('f{0}n'.format(t.n)).innerHTML = linksplit(esc(t.purl + t.name)).join(' ');
}
t.postlist = [];
@ -832,6 +828,11 @@ function up2k_init(have_crypto) {
var ofs = err.lastIndexOf(' : ');
if (ofs > 0)
err = err.slice(0, ofs);
ofs = err.indexOf('\n/');
if (ofs !== -1) {
err = err.slice(0, ofs + 1) + linksplit(err.slice(ofs + 2, -1)).join(' ');
}
}
if (err != "") {
ebi('f{0}t'.format(t.n)).innerHTML = "ERROR";
@ -858,7 +859,7 @@ function up2k_init(have_crypto) {
if (fsearch)
req.srch = 1;
xhr.open('POST', post_url + 'handshake.php', true);
xhr.open('POST', t.purl + 'handshake.php', true);
xhr.responseType = 'text';
xhr.send(JSON.stringify(req));
}
@ -916,7 +917,7 @@ function up2k_init(have_crypto) {
(xhr.responseText && xhr.responseText) ||
"no further information"));
};
xhr.open('POST', post_url + 'chunkpit.php', true);
xhr.open('POST', t.purl + 'chunkpit.php', true);
//xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart].substr(1) + "x");
xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]);
xhr.setRequestHeader("X-Up2k-Wark", t.wark);

View file

@ -35,14 +35,14 @@
text-align: center;
font-size: 1.5em;
margin: .5em auto;
padding: .6em 0;
padding: 1.2em 0;
width: 16em;
cursor: pointer;
box-shadow: .4em .4em 0 #111;
}
#u2conf #u2btn {
margin: -1em 0;
padding: .7em 0;
margin: -1.5em 0;
padding: 1.5em 0;
width: 100%;
}
#u2notbtn {
@ -206,7 +206,7 @@
bottom: 0;
background: #0a0;
}
.prog>a>span {
#u2tab a>span {
font-weight: bold;
font-style: italic;
color: #fff;

View file

@ -1,7 +1,7 @@
<div id="op_bup" class="opview opbox act">
<div id="u2err"></div>
<form method="post" enctype="multipart/form-data" accept-charset="utf-8" action="/{{ vdir }}">
<form method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="hidden" name="act" value="bput" />
<input type="file" name="f" multiple><br />
<input type="submit" value="start upload">
@ -9,7 +9,7 @@
</div>
<div id="op_mkdir" class="opview opbox act">
<form method="post" enctype="multipart/form-data" accept-charset="utf-8" action="/{{ vdir }}">
<form method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="hidden" name="act" value="mkdir" />
<input type="text" name="name" size="30">
<input type="submit" value="mkdir">
@ -17,7 +17,7 @@
</div>
<div id="op_new_md" class="opview opbox">
<form method="post" enctype="multipart/form-data" accept-charset="utf-8" action="/{{ vdir }}">
<form method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="hidden" name="act" value="new_md" />
<input type="text" name="name" size="30">
<input type="submit" value="create doc">
@ -25,7 +25,7 @@
</div>
<div id="op_msg" class="opview opbox">
<form method="post" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" action="/{{ vdir }}">
<form method="post" enctype="application/x-www-form-urlencoded" accept-charset="utf-8">
<input type="text" name="msg" size="30">
<input type="submit" value="send msg">
</form>

View file

@ -174,6 +174,9 @@ function goto(dest) {
function linksplit(rp) {
var ret = [];
var apath = '/';
if (rp && rp.charAt(0) == '/')
rp = rp.slice(1);
while (rp) {
var link = rp;
var ofs = rp.indexOf('/');