From 27451469fa73fecfb93d7c98334f4a40c79b4c19 Mon Sep 17 00:00:00 2001 From: antanilol <93981288+antanilol@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:29:41 +0100 Subject: [PATCH] Add eXact Length parameter when creating magnet URI Include the `xl` (eXact Length) parameter in the magnet URI string inside the function `TorrentImpl::createMagnetURI()`. Closes #20752. PR #21958. --- src/base/bittorrent/torrentimpl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 5a2b6aac9..de6d12c5d 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -2863,6 +2863,11 @@ QString TorrentImpl::createMagnetURI() const ret += u"&dn=" + QString::fromLatin1(QUrl::toPercentEncoding(displayName)); } + if (hasMetadata()) + { + ret += u"&xl=" + QString::number(totalSize()); + } + for (const TrackerEntryStatus &tracker : asConst(trackers())) { ret += u"&tr=" + QString::fromLatin1(QUrl::toPercentEncoding(tracker.url));