From 757fca10591b841503e7cb906f1e48ec1e025104 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 2 Jul 2026 09:17:32 -0400 Subject: [PATCH] =?UTF-8?q?[edit]=20Host=20the=20.torrent=20(xs=3D)=20for?= =?UTF-8?q?=20edited=20external=20URLs=20too=20=E2=80=94=20close=20the=20g?= =?UTF-8?q?ap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The edit-modal external-URL webseed was ws=-only because the Edit modal had no storage credentials wired in. Reuse mediaUploader.resolveActiveConnection() (the same resolver the Edit modal's file-replace uploads use) to get the active provider + credentials when storage is unlocked, and pass them to deriveTorrentForExternalUrl so it hosts the tiny .torrent and emits ws=+xs= — full P2P bootstrap, matching the upload modal. Storage locked / no connection → ws=-only (unchanged, best-effort). Edit-modal submit-state + upload-field + external-url-torrent suites green. Lint + build green. Co-Authored-By: Claude Opus 4.8 --- js/ui/components/EditModal.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/js/ui/components/EditModal.js b/js/ui/components/EditModal.js index a76f0611..6c2523ee 100644 --- a/js/ui/components/EditModal.js +++ b/js/ui/components/EditModal.js @@ -1080,8 +1080,9 @@ export class EditModal { // with no magnet, so an edited external URL keeps the P2P benefit (magnet // ws=url). Best-effort + size-capped; on CORS / too-large / any error it stays // URL-only. Runs before the magnet normalization below so the derived magnet's - // ws/xs are extracted the same way a pasted magnet's are. (Hosting the tiny - // .torrent (xs=) on the edit path needs credential plumbing — a follow-up.) + // ws/xs are extracted the same way a pasted magnet's are. When storage is + // unlocked we also host the tiny .torrent (xs=) so the webseed can bootstrap + // P2P — same as the upload modal. if ( urlWasEdited && finalUrl && @@ -1089,9 +1090,24 @@ export class EditModal { typeof this.mediaUploader?.deriveTorrentForExternalUrl === "function" ) { try { + let connection = null; + try { + connection = + typeof this.mediaUploader.resolveActiveConnection === "function" + ? await this.mediaUploader.resolveActiveConnection() + : null; + } catch (connectionError) { + connection = null; + } + const canHostTorrent = Boolean( + connection?.unlocked && connection?.credentials && connection?.provider, + ); const derived = await this.mediaUploader.deriveTorrentForExternalUrl( finalUrl, - {}, + { + provider: canHostTorrent ? connection.provider : undefined, + credentials: canHostTorrent ? connection.credentials : undefined, + }, ); if (derived?.magnet) { finalMagnet = derived.magnet;