diff --git a/copyparty/up2k.py b/copyparty/up2k.py index adfeede9..97fcaf52 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -2092,7 +2092,16 @@ class Up2k(object): ) alts.append((score, -len(alts), j)) - job = sorted(alts, reverse=True)[0][2] if alts else None + if alts: + best = sorted(alts, reverse=True)[0] + job = best[2] + if best[0] == 5 and vfs.flags.get("rand") or cj.get("rand"): + # filenames are randomized; found dupe in same folder; + # perfect! return the original file + cj["name"] = job["name"] + else: + job = None + if job and wark in reg: # self.log("pop " + wark + " " + job["name"] + " handle_json db", 4) del reg[wark] @@ -2167,7 +2176,13 @@ class Up2k(object): job[k] = cj[k] pdir = djoin(cj["ptop"], cj["prel"]) - job["name"] = self._untaken(pdir, cj, now) + if vfs.flags.get("rand") or cj.get("rand"): + job["name"] = rand_name( + pdir, cj["name"], vfs.flags["nrand"] + ) + else: + job["name"] = self._untaken(pdir, cj, now) + dst = os.path.join(job["ptop"], job["prel"], job["name"]) if not self.args.nw: bos.unlink(dst) # TODO ed pls diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index a740e162..15b4447e 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -134,6 +134,7 @@ var Ls = { "wt_next": "next track$NHotkey: L", "ul_par": "parallel uploads:", + "ut_rand": "randomize filenames", "ut_mt": "continue hashing other files while uploading$N$Nmaybe disable if your CPU or HDD is a bottleneck", "ut_ask": "ask for confirmation before upload starts", "ut_pot": "improve upload speed on slow devices$Nby making the UI less complex", @@ -580,6 +581,7 @@ var Ls = { "wt_next": "neste sang$NSnarvei: L", "ul_par": "samtidige handl.:", + "ut_rand": "finn opp nye tilfeldige filnavn", "ut_mt": "fortsett å befare køen mens opplastning foregår$N$Nskru denne av dersom du har en$Ntreg prosessor eller harddisk", "ut_ask": "bekreft filutvalg før opplastning starter", "ut_pot": "forbedre ytelsen på trege enheter ved å$Nforenkle brukergrensesnittet", @@ -957,8 +959,8 @@ ebi('op_up2k').innerHTML = ( ' \n' + '
' + L.ul_par + '\n' + ' \n' + - ' \n' + - ' \n' + + ' \n' + + ' \n' + ' \n' + ' \n' + ' \n' + @@ -1075,6 +1077,7 @@ ebi('op_cfg').innerHTML = ( '
\n' + '

' + L.cl_uopts + '

\n' + '
\n' + + ' 🏃\n' + ' mt\n' + ' turbo\n' + ' date-chk\n' + diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index c7bf5ec5..6bc24a4f 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -856,6 +856,7 @@ function up2k_init(subtle) { fdom_ctr = 0, biggest_file = 0; + bcfg_bind(uc, 'rand', 'u2rand', false, null, false); bcfg_bind(uc, 'multitask', 'multitask', true, null, false); bcfg_bind(uc, 'potato', 'potato', false, set_potato, false); bcfg_bind(uc, 'ask_up', 'ask_up', true, null, false); @@ -1364,6 +1365,9 @@ function up2k_init(subtle) { if (uc.fsearch) entry.srch = 1; + if (uc.fsearch && uc.rand) + entry.rand = true; + if (biggest_file < entry.size) biggest_file = entry.size; @@ -2368,6 +2372,8 @@ function up2k_init(subtle) { }; if (t.srch) req.srch = 1; + if (t.rand) + req.rand = true; xhr.open('POST', t.purl, true); xhr.responseType = 'text';