Don't use deprecated libtorrent features

This commit is contained in:
Vladimir Golovnev (Glassez)
2019-07-18 19:53:04 +03:00
parent 7f3291c3de
commit 60ffa3030e
16 changed files with 130 additions and 186 deletions

View File

@@ -44,14 +44,17 @@
#include "base/global.h"
#include "base/utils/fs.h"
#include "base/utils/string.h"
#include "private/ltunderlyingtype.h"
namespace
{
#if (LIBTORRENT_VERSION_NUM < 10200)
using CreateFlags = int;
using LTCreateFlags = int;
using LTPieceIndex = int;
#else
using CreateFlags = lt::create_flags_t;
#endif
using LTCreateFlags = lt::create_flags_t;
using LTPieceIndex = lt::piece_index_t;
#endif
// do not include files and folders whose
// name starts with a .
@@ -136,7 +139,7 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return;
lt::create_torrent newTorrent(fs, m_params.pieceSize, -1
, (m_params.isAlignmentOptimized ? lt::create_torrent::optimize_alignment : CreateFlags {}));
, (m_params.isAlignmentOptimized ? lt::create_torrent::optimize_alignment : LTCreateFlags {}));
// Add url seeds
for (QString seed : asConst(m_params.urlSeeds)) {
@@ -157,7 +160,10 @@ void TorrentCreatorThread::run()
// calculate the hash for all pieces
lt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString()
, [this, &newTorrent](const int n) { sendProgressSignal(n, newTorrent.num_pieces()); });
, [this, &newTorrent](const LTPieceIndex n)
{
sendProgressSignal(LTUnderlyingType<LTPieceIndex> {n}, newTorrent.num_pieces());
});
// Set qBittorrent as creator and add user comment to
// torrent_info structure
newTorrent.set_creator(creatorStr.toUtf8().constData());
@@ -208,5 +214,5 @@ int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const i
lt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
return lt::create_torrent(fs, pieceSize, -1
, (isAlignmentOptimized ? lt::create_torrent::optimize_alignment : CreateFlags {})).num_pieces();
, (isAlignmentOptimized ? lt::create_torrent::optimize_alignment : LTCreateFlags {})).num_pieces();
}