mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 19:40:18 -07:00
Merge pull request #10474 from thalieht/backport
Backport #10464 to v4_1_x
This commit is contained in:
commit
bad603454b
4 changed files with 6 additions and 5 deletions
|
@ -2100,7 +2100,7 @@ bool Session::addTorrent(QString source, const AddTorrentParams ¶ms)
|
||||||
LogMsg(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source));
|
LogMsg(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(source));
|
||||||
// Launch downloader
|
// Launch downloader
|
||||||
Net::DownloadHandler *handler =
|
Net::DownloadHandler *handler =
|
||||||
Net::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(10485760 /* 10MB */).handleRedirectToMagnet(true));
|
Net::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE).handleRedirectToMagnet(true));
|
||||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
|
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
|
||||||
, this, &Session::handleDownloadFinished);
|
, this, &Session::handleDownloadFinished);
|
||||||
connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed);
|
connect(handler, &Net::DownloadHandler::downloadFailed, this, &Session::handleDownloadFailed);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
@ -105,10 +106,9 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString *error) noexc
|
||||||
return TorrentInfo();
|
return TorrentInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
const qint64 fileSizeLimit = 100 * 1024 * 1024; // 100 MB
|
if (file.size() > MAX_TORRENT_SIZE) {
|
||||||
if (file.size() > fileSizeLimit) {
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = tr("File size exceeds max limit %1").arg(fileSizeLimit);
|
*error = tr("File size exceeds max limit %1").arg(Utils::Misc::friendlyUnit(MAX_TORRENT_SIZE));
|
||||||
return TorrentInfo();
|
return TorrentInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
|
||||||
|
const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
|
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
|
||||||
|
|
|
@ -235,7 +235,7 @@ void AddNewTorrentDialog::show(QString source, const BitTorrent::AddTorrentParam
|
||||||
// Launch downloader
|
// Launch downloader
|
||||||
// TODO: Don't save loaded torrent to file, just use downloaded data!
|
// TODO: Don't save loaded torrent to file, just use downloaded data!
|
||||||
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
Net::DownloadHandler *handler = Net::DownloadManager::instance()->download(
|
||||||
Net::DownloadRequest(source).limit(10485760 /* 10MB */).handleRedirectToMagnet(true).saveToFile(true));
|
Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE).handleRedirectToMagnet(true).saveToFile(true));
|
||||||
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
|
||||||
, dlg, &AddNewTorrentDialog::handleDownloadFinished);
|
, dlg, &AddNewTorrentDialog::handleDownloadFinished);
|
||||||
connect(handler, &Net::DownloadHandler::downloadFailed, dlg, &AddNewTorrentDialog::handleDownloadFailed);
|
connect(handler, &Net::DownloadHandler::downloadFailed, dlg, &AddNewTorrentDialog::handleDownloadFailed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue