mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
up2k-cli: recover from tcp/dns issues on upload
This commit is contained in:
parent
12709a8a0a
commit
a2009bcc6b
|
@ -1359,11 +1359,7 @@ function up2k_init(subtle) {
|
||||||
if (cdr >= t.size)
|
if (cdr >= t.size)
|
||||||
cdr = t.size;
|
cdr = t.size;
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
function orz(xhr) {
|
||||||
xhr.upload.onprogress = function (xev) {
|
|
||||||
pvis.prog(t, npart, xev.loaded);
|
|
||||||
};
|
|
||||||
function orz() {
|
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
pvis.prog(t, npart, cdr - car);
|
pvis.prog(t, npart, cdr - car);
|
||||||
st.bytes.uploaded += cdr - car;
|
st.bytes.uploaded += cdr - car;
|
||||||
|
@ -1384,18 +1380,32 @@ function up2k_init(subtle) {
|
||||||
(xhr.responseText && xhr.responseText) ||
|
(xhr.responseText && xhr.responseText) ||
|
||||||
"no further information"));
|
"no further information"));
|
||||||
}
|
}
|
||||||
xhr.onload = function (xev) {
|
function do_send() {
|
||||||
try { orz(); } catch (ex) { vis_exh(ex + '', '', '', '', ex); }
|
var xhr = new XMLHttpRequest();
|
||||||
};
|
xhr.upload.onprogress = function (xev) {
|
||||||
xhr.open('POST', t.purl + 'chunkpit.php', true);
|
pvis.prog(t, npart, xev.loaded);
|
||||||
xhr.setRequestHeader("X-Up2k-Hash", t.hash[npart]);
|
};
|
||||||
xhr.setRequestHeader("X-Up2k-Wark", t.wark);
|
xhr.onload = function (xev) {
|
||||||
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
try { orz(xhr); } catch (ex) { vis_exh(ex + '', '', '', '', ex); }
|
||||||
if (xhr.overrideMimeType)
|
};
|
||||||
xhr.overrideMimeType('Content-Type', 'application/octet-stream');
|
xhr.onerror = function (xev) {
|
||||||
|
if (!window['vis_exh'])
|
||||||
|
return;
|
||||||
|
|
||||||
xhr.responseType = 'text';
|
console.log('chunkpit onerror, retrying', t);
|
||||||
xhr.send(bobslice.call(t.fobj, car, cdr));
|
do_send();
|
||||||
|
};
|
||||||
|
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');
|
||||||
|
|
||||||
|
xhr.responseType = 'text';
|
||||||
|
xhr.send(bobslice.call(t.fobj, car, cdr));
|
||||||
|
}
|
||||||
|
do_send();
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
|
Loading…
Reference in a new issue