mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
parallelize handshakes
This commit is contained in:
parent
c95941e14f
commit
a5120d4f6f
|
@ -622,6 +622,8 @@ in the `scripts` folder:
|
||||||
|
|
||||||
roughly sorted by priority
|
roughly sorted by priority
|
||||||
|
|
||||||
|
* keepalive handshake after 5h
|
||||||
|
* skip pushing postlist if todo.upload has entries
|
||||||
* readme.md as epilogue
|
* readme.md as epilogue
|
||||||
* reduce up2k roundtrips
|
* reduce up2k roundtrips
|
||||||
* start from a chunk index and just go
|
* start from a chunk index and just go
|
||||||
|
|
|
@ -607,13 +607,14 @@ class HttpCli(object):
|
||||||
os.makedirs(fsenc(dst))
|
os.makedirs(fsenc(dst))
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
self.log("makedirs failed [{}]".format(dst))
|
self.log("makedirs failed [{}]".format(dst))
|
||||||
if ex.errno == 13:
|
if not os.path.isdir(fsenc(dst)):
|
||||||
raise Pebkac(500, "the server OS denied write-access")
|
if ex.errno == 13:
|
||||||
|
raise Pebkac(500, "the server OS denied write-access")
|
||||||
|
|
||||||
if ex.errno == 17:
|
if ex.errno == 17:
|
||||||
raise Pebkac(400, "some file got your folder name")
|
raise Pebkac(400, "some file got your folder name")
|
||||||
|
|
||||||
raise Pebkac(500, min_ex())
|
raise Pebkac(500, min_ex())
|
||||||
except:
|
except:
|
||||||
raise Pebkac(500, min_ex())
|
raise Pebkac(500, min_ex())
|
||||||
|
|
||||||
|
|
|
@ -612,7 +612,7 @@ function up2k_init(subtle) {
|
||||||
}
|
}
|
||||||
else files = e.target.files;
|
else files = e.target.files;
|
||||||
|
|
||||||
if (!files || files.length == 0)
|
if (!files || !files.length)
|
||||||
return alert('no files selected??');
|
return alert('no files selected??');
|
||||||
|
|
||||||
more_one_file();
|
more_one_file();
|
||||||
|
@ -837,13 +837,20 @@ function up2k_init(subtle) {
|
||||||
//
|
//
|
||||||
|
|
||||||
function handshakes_permitted() {
|
function handshakes_permitted() {
|
||||||
var lim = multitask ? 1 : 0;
|
// verification
|
||||||
|
if (st.todo.handshake.length &&
|
||||||
|
st.todo.handshake[0].t4)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (lim <
|
if ((multitask ? 2 : 0) <
|
||||||
st.todo.upload.length +
|
st.todo.upload.length +
|
||||||
st.busy.upload.length)
|
st.busy.upload.length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (parallel_uploads <
|
||||||
|
st.busy.handshake.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
var cd = st.todo.handshake.length ? st.todo.handshake[0].cooldown : 0;
|
var cd = st.todo.handshake.length ? st.todo.handshake[0].cooldown : 0;
|
||||||
if (cd && cd - Date.now() > 0)
|
if (cd && cd - Date.now() > 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -917,22 +924,8 @@ function up2k_init(subtle) {
|
||||||
st.todo.handshake.unshift(t);
|
st.todo.handshake.unshift(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st.todo.handshake.length > 0 &&
|
|
||||||
st.busy.handshake.length == 0 && (
|
|
||||||
st.todo.handshake[0].t4 || (
|
|
||||||
handshakes_permitted() &&
|
|
||||||
st.busy.upload.length < parallel_uploads
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
exec_handshake();
|
|
||||||
mou_ikkai = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handshakes_permitted() &&
|
if (handshakes_permitted() &&
|
||||||
st.todo.handshake.length > 0 &&
|
st.todo.handshake.length) {
|
||||||
st.busy.handshake.length == 0 &&
|
|
||||||
st.busy.upload.length < parallel_uploads) {
|
|
||||||
exec_handshake();
|
exec_handshake();
|
||||||
mou_ikkai = true;
|
mou_ikkai = true;
|
||||||
}
|
}
|
||||||
|
@ -945,7 +938,7 @@ function up2k_init(subtle) {
|
||||||
|
|
||||||
if (hashing_permitted() &&
|
if (hashing_permitted() &&
|
||||||
st.todo.hash.length > 0 &&
|
st.todo.hash.length > 0 &&
|
||||||
st.busy.hash.length == 0) {
|
!st.busy.hash.length) {
|
||||||
exec_hash();
|
exec_hash();
|
||||||
mou_ikkai = true;
|
mou_ikkai = true;
|
||||||
}
|
}
|
||||||
|
@ -1376,7 +1369,7 @@ function up2k_init(subtle) {
|
||||||
}
|
}
|
||||||
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
st.busy.upload.splice(st.busy.upload.indexOf(upt), 1);
|
||||||
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
t.postlist.splice(t.postlist.indexOf(npart), 1);
|
||||||
if (t.postlist.length == 0) {
|
if (!t.postlist.length) {
|
||||||
t.t4 = Date.now();
|
t.t4 = Date.now();
|
||||||
pvis.seth(t.n, 1, 'verifying');
|
pvis.seth(t.n, 1, 'verifying');
|
||||||
st.todo.handshake.unshift(t);
|
st.todo.handshake.unshift(t);
|
||||||
|
|
Loading…
Reference in a new issue