Browse Source

Increase the download size limit to 100 MiB

adaptive-webui-19844
thalieht 6 years ago
parent
commit
25102b9c5d
  1. 2
      src/base/bittorrent/session.cpp
  2. 6
      src/base/bittorrent/torrentinfo.cpp
  3. 1
      src/base/global.h
  4. 2
      src/gui/addnewtorrentdialog.cpp

2
src/base/bittorrent/session.cpp

@ -1809,7 +1809,7 @@ bool Session::addTorrent(const QString &source, const AddTorrentParams &params)
if (Net::DownloadManager::hasSupportedScheme(source)) { if (Net::DownloadManager::hasSupportedScheme(source)) {
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::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(10485760 /* 10MB */) Net::DownloadManager::instance()->download(Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE)
, this, &Session::handleDownloadFinished); , this, &Session::handleDownloadFinished);
m_downloadedTorrents[source] = params; m_downloadedTorrents[source] = params;
return true; return true;

6
src/base/bittorrent/torrentinfo.cpp

@ -39,6 +39,7 @@
#include <QStringList> #include <QStringList>
#include <QUrl> #include <QUrl>
#include "base/global.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "infohash.h" #include "infohash.h"
#include "trackerentry.h" #include "trackerentry.h"
@ -116,10 +117,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(MAX_TORRENT_SIZE);
return TorrentInfo(); return TorrentInfo();
} }

1
src/base/global.h

@ -36,6 +36,7 @@
#endif #endif
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; }

2
src/gui/addnewtorrentdialog.cpp

@ -238,7 +238,7 @@ void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorre
if (Net::DownloadManager::hasSupportedScheme(source)) { if (Net::DownloadManager::hasSupportedScheme(source)) {
// Launch downloader // Launch downloader
Net::DownloadManager::instance()->download( Net::DownloadManager::instance()->download(
Net::DownloadRequest(source).limit(10485760 /* 10MB */) Net::DownloadRequest(source).limit(MAX_TORRENT_SIZE)
, dlg, &AddNewTorrentDialog::handleDownloadFinished); , dlg, &AddNewTorrentDialog::handleDownloadFinished);
return; return;
} }

Loading…
Cancel
Save