Browse Source

Merge pull request #8811 from sledgehammer999/fix_RC_1_0

Fix compilation against libtorrent 1.0.x
adaptive-webui-19844
sledgehammer999 7 years ago committed by GitHub
parent
commit
55c98d8706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/base/bittorrent/torrentcreatorthread.cpp
  2. 9
      src/base/bittorrent/torrentinfo.cpp

12
src/base/bittorrent/torrentcreatorthread.cpp

@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
#include <libtorrent/create_torrent.hpp>
#include <libtorrent/storage.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/version.hpp>
#include <QDirIterator>
#include <QFile>
@ -133,8 +134,13 @@ void TorrentCreatorThread::run() @@ -133,8 +134,13 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return;
#if LIBTORRENT_VERSION_NUM < 10100
libt::create_torrent newTorrent(fs, m_params.pieceSize, -1
, (m_params.isAlignmentOptimized ? libt::create_torrent::optimize : 0));
#else
libt::create_torrent newTorrent(fs, m_params.pieceSize, -1
, (m_params.isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0));
#endif
// Add url seeds
foreach (QString seed, m_params.urlSeeds) {
@ -204,6 +210,12 @@ int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const i @@ -204,6 +210,12 @@ int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const i
libt::file_storage fs;
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
#if LIBTORRENT_VERSION_NUM < 10100
return libt::create_torrent(fs, pieceSize, -1
, (isAlignmentOptimized ? libt::create_torrent::optimize : 0)).num_pieces();
#else
return libt::create_torrent(fs, pieceSize, -1
, (isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0)).num_pieces();
#endif
}

9
src/base/bittorrent/torrentinfo.cpp

@ -106,10 +106,17 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString *error) noexc @@ -106,10 +106,17 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString *error) noexc
// used in `torrent_info()` constructor
const int depthLimit = 100;
const int tokenLimit = 10000000;
libt::bdecode_node node;
libt::error_code ec;
#if LIBTORRENT_VERSION_NUM < 10100
libt::lazy_entry node;
libt::lazy_bdecode(data.constData(), (data.constData() + data.size()), node, ec
, nullptr, depthLimit, tokenLimit);
#else
libt::bdecode_node node;
bdecode(data.constData(), (data.constData() + data.size()), node, ec
, nullptr, depthLimit, tokenLimit);
#endif
if (ec) {
if (error)
*error = QString::fromStdString(ec.message());

Loading…
Cancel
Save