From 782084056d9e4684158686b0903c312b6264e96c Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 15 Mar 2025 21:16:54 +0000 Subject: [PATCH] filter appledoubles from uploads should catch all the garbage that macs sprinkle onto flashdrives; https://a.ocv.me/pub/stuff/?doc=appledoubles-and-friends.txt will notice and suggest to skip the following files/dirs: * __MACOSX * .DS_Store * .AppleDouble * .LSOverride * .DocumentRevisions-* * .fseventsd * .Spotlight-V* * .TemporaryItems * .Trashes * .VolumeIcon.icns * .com.apple.timemachine.donotpresent * .AppleDB * .AppleDesktop * .apdisk and conditionally ._foo.jpg if foo.jpg is also being uploaded --- copyparty/web/browser.js | 3 ++ copyparty/web/up2k.js | 68 ++++++++++++++++++++++++++++++++++++---- scripts/tl.js | 18 +++++++++-- 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 47a22d76..d82290e0 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -542,6 +542,7 @@ var Ls = { "u_enoow": "overwrite will not work here; need Delete-permission", "u_badf": 'These {0} files (of {1} total) were skipped, possibly due to filesystem permissions:\n\n', "u_blankf": 'These {0} files (of {1} total) are blank / empty; upload them anyways?\n\n', + "u_applef": 'These {0} files (of {1} total) are probably undesirable;\nPress OK/Enter to SKIP the following files,\nPress Cancel/ESC to NOT exclude, and UPLOAD those as well:\n\n', "u_just1": '\nMaybe it works better if you select just one file', "u_ff_many": "if you're using Linux / MacOS / Android, then this amount of files may crash Firefox!\nif that happens, please try again (or use Chrome).", "u_up_life": "This upload will be deleted from the server\n{0} after it completes", @@ -1144,6 +1145,7 @@ var Ls = { "u_enoow": "kan ikke overskrive filer her (Delete-rettigheten er nødvendig)", "u_badf": 'Disse {0} filene (av totalt {1}) kan ikke leses, kanskje pga rettighetsproblemer i filsystemet på datamaskinen din:\n\n', "u_blankf": 'Disse {0} filene (av totalt {1}) er blanke / uten innhold; ønsker du å laste dem opp uansett?\n\n', + "u_applef": 'Disse {0} filene (av totalt {1}) er antagelig uønskede;\nTrykk OK/Enter for å HOPPE OVER disse filene,\nTrykk Avbryt/ESC for å LASTE OPP disse filene også:\n\n', "u_just1": '\nFunker kanskje bedre hvis du bare tar én fil om gangen', "u_ff_many": 'Hvis du bruker Linux / MacOS / Android, så kan dette antallet filer
kanskje krasje Firefox! Hvis det skjer, så prøv igjen (eller bruk Chrome).', "u_up_life": "Filene slettes fra serveren {0}\netter at opplastningen er fullført", @@ -1746,6 +1748,7 @@ var Ls = { "u_enoow": "无法覆盖此处的文件;需要删除权限", //m "u_badf": '这些 {0} 个文件(共 {1} 个)被跳过,可能是由于文件系统权限:\n\n', "u_blankf": '这些 {0} 个文件(共 {1} 个)是空白的;是否仍然上传?\n\n', + "u_applef": "这些 {0} 个文件(共 {1} 个)可能是不需要的;\n按 确定/Enter 跳过以下文件,\n按 取消/ESC 取消排除,并上传这些文件:\n\n", //m "u_just1": '\n也许如果你只选择一个文件会更好', "u_ff_many": "如果你使用的是 Linux / MacOS / Android, 那么这个文件数量 可能 崩溃 Firefox!\n如果发生这种情况,请再试一次(或使用 Chrome)。", "u_up_life": "此上传将在 {0} 后从服务器删除", diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index a0fa380b..599eda02 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -1343,10 +1343,68 @@ function up2k_init(subtle) { }); } + var fps = new Set(), pdp = ''; + for (var a = 0; a < good_files.length; a++) { + var fp = good_files[a][1], + dp = vsplit(fp)[0]; + fps.add(fp); + if (pdp != dp) { + pdp = dp; + dp = dp.slice(0, -1); + while (dp) { + fps.add(dp); + dp = vsplit(dp)[0].slice(0, -1); + } + } + } + + var junk = [], rmi = []; + for (var a = 0; a < good_files.length; a++) { + var fn = good_files[a][1]; + if (fn.indexOf("/.") < 0 && fn.indexOf("/__MACOS") < 0) + continue; + + if (/\/__MACOS|\/\.(DS_Store|AppleDouble|LSOverride|DocumentRevisions-|fseventsd|Spotlight-V[0-9]|TemporaryItems|Trashes|VolumeIcon\.icns|com\.apple\.timemachine\.donotpresent|AppleDB|AppleDesktop|apdisk)/.exec(fn)) { + junk.push(good_files[a]); + rmi.push(a); + continue; + } + + if (fn.indexOf("/._") + 1 && + fps.has(fn.replace("/._", "/")) && + fn.split("/").pop().startsWith("._") && + !has(rmi, a) + ) { + junk.push(good_files[a]); + rmi.push(a); + } + } + + if (!junk.length) + return gotallfiles2(good_files); + + junk.sort(); + rmi.sort(function (a, b) { return a - b; }); + + var msg = L.u_applef.format(junk.length, good_files.length); + for (var a = 0, aa = Math.min(1000, junk.length); a < aa; a++) + msg += '-- ' + esc(junk[a][1]) + '\n'; + + return modal.confirm(msg, function () { + for (var a = rmi.length - 1; a >= 0; a--) + good_files.splice(rmi[a], 1); + + start_actx(); + gotallfiles2(good_files); + }, function () { + start_actx(); + gotallfiles2(good_files); + }); + } + + function gotallfiles2(good_files) { good_files.sort(function (a, b) { - a = a[1]; - b = b[1]; - return a < b ? -1 : a > b ? 1 : 0; + return a[1] < b[1] ? -1 : 1; }); var msg = []; @@ -1399,9 +1457,7 @@ function up2k_init(subtle) { if (!uc.az) good_files.sort(function (a, b) { - a = a[0].size; - b = b[0].size; - return a < b ? -1 : a > b ? 1 : 0; + return a[0].size - b[0].size; }); for (var a = 0; a < good_files.length; a++) { diff --git a/scripts/tl.js b/scripts/tl.js index 95daaea8..4e52a077 100644 --- a/scripts/tl.js +++ b/scripts/tl.js @@ -148,6 +148,7 @@ var tl_browser = { ["U/O", "skip 10sec back/fwd"], ["0..9", "jump to 0%..90%"], ["P", "play/pause (also initiates)"], + ["S", "select playing song"], ["Y", "download song"], ], [ "image-viewer", @@ -156,6 +157,7 @@ var tl_browser = { ["F", "fullscreen"], ["R", "rotate clockwise"], ["🡅 R", "rotate ccw"], + ["S", "select pic"], ["Y", "download pic"], ], [ "video-player", @@ -235,7 +237,8 @@ var tl_browser = { "ul_par": "parallel uploads:", "ut_rand": "randomize filenames", - "ut_u2ts": "copy the last-modified timestamp$Nfrom your filesystem to the server", + "ut_u2ts": "copy the last-modified timestamp$Nfrom your filesystem to the server\">📅", + "ut_ow": "overwrite existing files on the server?$N🛡️: never (will generate a new filename instead)$N🕒: overwrite if server-file is older than yours$N♻️: always overwrite if the files are different", "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", @@ -327,7 +330,7 @@ var tl_browser = { "cut_nag": "OS notification when upload completes$N(only if the browser or tab is not active)", "cut_sfx": "audible alert when upload completes$N(only if the browser or tab is not active)", - "cut_mt": "use multithreading to accelerate file hashing$N$Nthis uses web-workers and requires$Nmore RAM (up to 512 MiB extra)$N$N30% faster https, 4.5x faster http,$Nand 5.3x faster on android phones\">mt", + "cut_mt": "use multithreading to accelerate file hashing$N$Nthis uses web-workers and requires$Nmore RAM (up to 512 MiB extra)$N$Nmakes https 30% faster, http 4.5x faster\">mt", "cft_text": "favicon text (blank and refresh to disable)", "cft_fg": "foreground color", @@ -349,6 +352,7 @@ var tl_browser = { "ml_pmode": "at end of folder...", "ml_btns": "cmds", "ml_tcode": "transcode", + "ml_tcode2": "transcode to", "ml_tint": "tint", "ml_eq": "audio equalizer", "ml_drc": "dynamic range compressor", @@ -372,6 +376,14 @@ var tl_browser = { "mt_cflac": "convert flac / wav to opus\">flac", "mt_caac": "convert aac / m4a to opus\">aac", "mt_coth": "convert all others (not mp3) to opus\">oth", + "mt_c2opus": "best choice for desktops, laptops, android\">opus", + "mt_c2owa": "opus-weba, for iOS 17.5 and newer\">owa", + "mt_c2caf": "opus-caf, for iOS 11 through 17\">caf", + "mt_c2mp3": "use this on very old devices\">mp3", + "mt_c2ok": "nice, good choice", + "mt_c2nd": "that's not the recommended output format for your device, but that's fine", + "mt_c2ng": "your device does not seem to support this output format, but let's try anyways", + "mt_xowa": "there are bugs in iOS preventing background playback using this format; please use caf or mp3 instead", "mt_tint": "background level (0-100) on the seekbar$Nto make buffering less distracting", "mt_eq": "enables the equalizer and gain control;$N$Nboost <code>0</code> = standard 100% volume (unmodified)$N$Nwidth <code>1  </code> = standard stereo (unmodified)$Nwidth <code>0.5</code> = 50% left-right crossfeed$Nwidth <code>0  </code> = mono$N$Nboost <code>-0.8</code> & width <code>10</code> = vocal removal :^)$N$Nenabling the equalizer makes gapless albums fully gapless, so leave it on with all the values at zero (except width = 1) if you care about that", "mt_drc": "enables the dynamic range compressor (volume flattener / brickwaller); will also enable EQ to balance the spaghetti, so set all EQ fields except for 'width' to 0 if you don't want it$N$Nlowers the volume of audio above THRESHOLD dB; for every RATIO dB past THRESHOLD there is 1 dB of output, so default values of tresh -24 and ratio 12 means it should never get louder than -22 dB and it is safe to increase the equalizer boost to 0.8, or even 1.8 with ATK 0 and a huge RLS like 90 (only works in firefox; RLS is max 1 in other browsers)$N$N(see wikipedia, they explain it much better)", @@ -613,8 +625,10 @@ var tl_browser = { "u_ewrite": 'you do not have write-access to this folder', "u_eread": 'you do not have read-access to this folder', "u_enoi": 'file-search is not enabled in server config', + "u_enoow": "overwrite will not work here; need Delete-permission", "u_badf": 'These {0} files (of {1} total) were skipped, possibly due to filesystem permissions:\n\n', "u_blankf": 'These {0} files (of {1} total) are blank / empty; upload them anyways?\n\n', + "u_applef": 'These {0} files (of {1} total) are probably undesirable;\nPress OK/Enter to SKIP the following files,\nPress Cancel/ESC to NOT exclude, and UPLOAD those as well:\n\n', "u_just1": '\nMaybe it works better if you select just one file', "u_ff_many": "if you're using Linux / MacOS / Android, then this amount of files may crash Firefox!\nif that happens, please try again (or use Chrome).", "u_up_life": "This upload will be deleted from the server\n{0} after it completes",