Skip to content

Commit

Permalink
up2k.js: bump handshake timeout for safededup
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Sep 8, 2024
1 parent a2e0f98 commit c5988a0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,8 @@ below are some tweaks roughly ordered by usefulness:
* `-q` disables logging and can help a bunch, even when combined with `-lo` to redirect logs to file
* `--hist` pointing to a fast location (ssd) will make directory listings and searches faster when `-e2d` or `-e2t` is set
* and also makes thumbnails load faster, regardless of e2d/e2t
* `--dedup` enables deduplication and thus avoids writing to the HDD if someone uploads a dupe
* `--safe-dedup 1` makes deduplication much faster during upload by skipping verification of file contents; safe if there is no other software editing/moving the files in the volumes
* `--no-hash .` when indexing a network-disk if you don't care about the actual filehashes and only want the names/tags searchable
* if your volumes are on a network-disk such as NFS / SMB / s3, specifying larger values for `--iobuf` and/or `--s-rd-sz` and/or `--s-wr-sz` may help; try setting all of them to `524288` or `1048576` or `4194304`
* `--no-htp --hash-mt=0 --mtag-mt=1 --th-mt=1` minimizes the number of threads; can help in some eccentric environments (like the vscode debugger)
Expand Down
2 changes: 1 addition & 1 deletion copyparty/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def vf_bmap() -> dict[str, str]:
"no_thumb": "dthumb",
"no_vthumb": "dvthumb",
"no_athumb": "dathumb",
"safe_dedup": "safededup",
}
for k in (
"dedup",
Expand Down Expand Up @@ -59,6 +58,7 @@ def vf_vmap() -> dict[str, str]:
"no_hash": "nohash",
"no_idx": "noidx",
"re_maxage": "scan",
"safe_dedup": "safededup",
"th_convt": "convt",
"th_size": "thsize",
"th_crop": "crop",
Expand Down
2 changes: 1 addition & 1 deletion copyparty/up2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ def _handle_json(self, cj: dict[str, Any], depth: int = 1) -> dict[str, Any]:
jcur = self.cur.get(ptop)
reg = self.registry[ptop]
vfs = self.asrv.vfs.all_vols[cj["vtop"]]
n4g = vfs.flags.get("noforget")
n4g = bool(vfs.flags.get("noforget"))
rand = vfs.flags.get("rand") or cj.get("rand")
lost: list[tuple["sqlite3.Cursor", str, str]] = []

Expand Down
3 changes: 3 additions & 0 deletions copyparty/web/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ var Ls = {
"u_etaprep": '(preparing to upload)',
"u_hashdone": 'hashing done',
"u_hashing": 'hash',
"u_hs": 'handshaking...',
"u_dupdefer": "duplicate; will be processed after all other files",
"u_actx": "click this text to prevent loss of<br />performance when switching to other windows/tabs",
"u_fixed": "OK!&nbsp; Fixed it 👍",
Expand Down Expand Up @@ -1081,6 +1082,7 @@ var Ls = {
"u_etaprep": '(forbereder opplastning)',
"u_hashdone": 'befaring ferdig',
"u_hashing": 'les',
"u_hs": 'serveren tenker...',
"u_dupdefer": "duplikat; vil bli håndtert til slutt",
"u_actx": "klikk her for å forhindre tap av<br />ytelse ved bytte til andre vinduer/faner",
"u_fixed": "OK!&nbsp; Løste seg 👍",
Expand Down Expand Up @@ -1644,6 +1646,7 @@ var Ls = {
"u_etaprep": '(准备上传)',
"u_hashdone": '哈希完成',
"u_hashing": '哈希',
"u_hs": '正在等待服务器...', //m
"u_dupdefer": "这是一个重复文件。它将在所有其他文件上传后进行处理", //m
"u_actx": "单击此文本以防止切换到其他窗口/选项卡时性能下降", //m
"u_fixed": "好!&nbsp;已修复 👍",
Expand Down
14 changes: 5 additions & 9 deletions copyparty/web/up2k.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,14 +1745,6 @@ function up2k_init(subtle) {

var mou_ikkai = false;

if (st.busy.handshake.length &&
st.busy.handshake[0].t_busied < now - 30 * 1000
) {
console.log("retrying stuck handshake");
var t = st.busy.handshake.shift();
st.todo.handshake.unshift(t);
}

var nprev = -1;
for (var a = 0; a < st.todo.upload.length; a++) {
var nf = st.todo.upload[a].nfile;
Expand Down Expand Up @@ -2254,6 +2246,9 @@ function up2k_init(subtle) {
if (keepalive)
console.log("sending keepalive handshake", t.name, t);

if (!t.srch && !t.t_handshake)
pvis.seth(t.n, 2, L.u_hs);

var xhr = new XMLHttpRequest();
xhr.onerror = xhr.ontimeout = function () {
if (t.t_busied != me) // t.done ok
Expand Down Expand Up @@ -2533,7 +2528,8 @@ function up2k_init(subtle) {

xhr.open('POST', t.purl, true);
xhr.responseType = 'text';
xhr.timeout = 42000;
xhr.timeout = 42000 + (t.srch || t.t_uploaded ? 0 :
(t.size / (1048 * 20))); // safededup 20M/s hdd
xhr.send(JSON.stringify(req));
}

Expand Down

0 comments on commit c5988a0

Please sign in to comment.