mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
up2k: gotta go faster
This commit is contained in:
parent
746a8208aa
commit
2b2415a7d8
|
@ -1223,6 +1223,8 @@ function up2k_init(have_crypto) {
|
||||||
|
|
||||||
var npart = upt.npart;
|
var npart = upt.npart;
|
||||||
var t = st.files[upt.nfile];
|
var t = st.files[upt.nfile];
|
||||||
|
if (!t.t3)
|
||||||
|
t.t3 = new Date().getTime();
|
||||||
|
|
||||||
pvis.seth(t.n, 1, "🚀 send");
|
pvis.seth(t.n, 1, "🚀 send");
|
||||||
|
|
||||||
|
@ -1232,54 +1234,40 @@ function up2k_init(have_crypto) {
|
||||||
if (cdr >= t.size)
|
if (cdr >= t.size)
|
||||||
cdr = t.size;
|
cdr = t.size;
|
||||||
|
|
||||||
var reader = new FileReader();
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.upload.onprogress = function (xev) {
|
||||||
reader.onerror = function () {
|
pvis.prog(t, npart, xev.loaded);
|
||||||
alert('y o u b r o k e i t\nerror: ' + reader.error);
|
|
||||||
};
|
};
|
||||||
|
xhr.onload = function (xev) {
|
||||||
reader.onload = function (e) {
|
if (xhr.status == 200) {
|
||||||
var xhr = new XMLHttpRequest();
|
pvis.prog(t, npart, cdr - car);
|
||||||
xhr.upload.onprogress = function (xev) {
|
st.bytes.uploaded += cdr - car;
|
||||||
pvis.prog(t, npart, xev.loaded);
|
t.bytes_uploaded += cdr - car;
|
||||||
};
|
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
||||||
xhr.onload = function (xev) {
|
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
||||||
if (xhr.status == 200) {
|
if (t.postlist.length == 0) {
|
||||||
pvis.prog(t, npart, cdr - car);
|
t.t4 = new Date().getTime();
|
||||||
st.bytes.uploaded += cdr - car;
|
pvis.seth(t.n, 1, 'verifying');
|
||||||
t.bytes_uploaded += cdr - car;
|
st.todo.handshake.unshift(t);
|
||||||
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
|
||||||
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
|
||||||
if (t.postlist.length == 0) {
|
|
||||||
t.t4 = new Date().getTime();
|
|
||||||
pvis.seth(t.n, 1, 'verifying');
|
|
||||||
st.todo.handshake.unshift(t);
|
|
||||||
}
|
|
||||||
tasker();
|
|
||||||
}
|
}
|
||||||
else
|
tasker();
|
||||||
alert("server broke; cu-err {0} on file [{1}]:\n".format(
|
}
|
||||||
xhr.status, t.name) + (
|
else
|
||||||
(xhr.response && xhr.response.err) ||
|
alert("server broke; cu-err {0} on file [{1}]:\n".format(
|
||||||
(xhr.responseText && xhr.responseText) ||
|
xhr.status, t.name) + (
|
||||||
"no further information"));
|
(xhr.response && xhr.response.err) ||
|
||||||
};
|
(xhr.responseText && xhr.responseText) ||
|
||||||
xhr.open('POST', t.purl + 'chunkpit.php', true);
|
"no further information"));
|
||||||
//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);
|
|
||||||
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
|
||||||
if (xhr.overrideMimeType)
|
|
||||||
xhr.overrideMimeType('Content-Type', 'application/octet-stream');
|
|
||||||
|
|
||||||
xhr.responseType = 'text';
|
|
||||||
xhr.send(e.target.result);
|
|
||||||
|
|
||||||
if (!t.t3)
|
|
||||||
t.t3 = new Date().getTime();
|
|
||||||
};
|
};
|
||||||
|
xhr.open('POST', t.purl + 'chunkpit.php', true);
|
||||||
|
xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]);
|
||||||
|
xhr.setRequestHeader("X-Up2k-Wark", t.wark);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
||||||
|
if (xhr.overrideMimeType)
|
||||||
|
xhr.overrideMimeType('Content-Type', 'application/octet-stream');
|
||||||
|
|
||||||
reader.readAsArrayBuffer(bobslice.call(t.fobj, car, cdr));
|
xhr.responseType = 'text';
|
||||||
|
xhr.send(bobslice.call(t.fobj, car, cdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
|
Loading…
Reference in a new issue