mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -06:00
Merge pull request #14138 from glassez/add-torrent
Use single parameter to accept torrent source
This commit is contained in:
@@ -2038,14 +2038,14 @@ bool Session::addTorrent(const MagnetUri &magnetUri, const AddTorrentParams &par
|
||||
{
|
||||
if (!magnetUri.isValid()) return false;
|
||||
|
||||
return addTorrent_impl(params, magnetUri);
|
||||
return addTorrent_impl(magnetUri, params);
|
||||
}
|
||||
|
||||
bool Session::addTorrent(const TorrentInfo &torrentInfo, const AddTorrentParams ¶ms)
|
||||
{
|
||||
if (!torrentInfo.isValid()) return false;
|
||||
|
||||
return addTorrent_impl(params, MagnetUri(), torrentInfo);
|
||||
return addTorrent_impl(torrentInfo, params);
|
||||
}
|
||||
|
||||
LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorrentParams)
|
||||
@@ -2080,9 +2080,11 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
|
||||
}
|
||||
|
||||
// Add a torrent to the BitTorrent session
|
||||
bool Session::addTorrent_impl(const AddTorrentParams &addTorrentParams, const MagnetUri &magnetUri, TorrentInfo metadata)
|
||||
bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source, const AddTorrentParams &addTorrentParams)
|
||||
{
|
||||
const bool hasMetadata = metadata.isValid();
|
||||
const bool hasMetadata = std::holds_alternative<TorrentInfo>(source);
|
||||
TorrentInfo metadata = (hasMetadata ? std::get<TorrentInfo>(source) : TorrentInfo {});
|
||||
const MagnetUri &magnetUri = (hasMetadata ? MagnetUri {} : std::get<MagnetUri>(source));
|
||||
const InfoHash hash = (hasMetadata ? metadata.hash() : magnetUri.hash());
|
||||
|
||||
// It looks illogical that we don't just use an existing handle,
|
||||
|
||||
Reference in New Issue
Block a user