mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
@@ -41,15 +41,10 @@
|
||||
#include <libtorrent/alert_types.hpp>
|
||||
#include <libtorrent/entry.hpp>
|
||||
#include <libtorrent/magnet_uri.hpp>
|
||||
#include <libtorrent/storage_defs.hpp>
|
||||
#include <libtorrent/time.hpp>
|
||||
#include <libtorrent/version.hpp>
|
||||
|
||||
#if (LIBTORRENT_VERSION_NUM >= 10200)
|
||||
#include <libtorrent/storage_defs.hpp>
|
||||
#include <libtorrent/write_resume_data.hpp>
|
||||
#else
|
||||
#include <libtorrent/storage.hpp>
|
||||
#endif
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QDebug>
|
||||
@@ -77,7 +72,6 @@ const QString QB_EXT {QStringLiteral(".!qB")};
|
||||
|
||||
using namespace BitTorrent;
|
||||
|
||||
#if (LIBTORRENT_VERSION_NUM >= 10200)
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace aux
|
||||
@@ -89,30 +83,19 @@ namespace libtorrent
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
using LTDownloadPriority = int;
|
||||
using LTPieceIndex = int;
|
||||
using LTQueuePosition = int;
|
||||
#else
|
||||
using LTDownloadPriority = lt::download_priority_t;
|
||||
using LTPieceIndex = lt::piece_index_t;
|
||||
using LTQueuePosition = lt::queue_position_t;
|
||||
#endif
|
||||
|
||||
std::vector<LTDownloadPriority> toLTDownloadPriorities(const QVector<DownloadPriority> &priorities)
|
||||
std::vector<lt::download_priority_t> toLTDownloadPriorities(const QVector<DownloadPriority> &priorities)
|
||||
{
|
||||
std::vector<LTDownloadPriority> out;
|
||||
std::vector<lt::download_priority_t> out;
|
||||
out.reserve(priorities.size());
|
||||
|
||||
std::transform(priorities.cbegin(), priorities.cend()
|
||||
, std::back_inserter(out), [](BitTorrent::DownloadPriority priority)
|
||||
{
|
||||
return static_cast<LTDownloadPriority>(
|
||||
static_cast<LTUnderlyingType<LTDownloadPriority>>(priority));
|
||||
return static_cast<lt::download_priority_t>(
|
||||
static_cast<LTUnderlyingType<lt::download_priority_t>>(priority));
|
||||
});
|
||||
return out;
|
||||
}
|
||||
@@ -371,23 +354,15 @@ QString TorrentHandleImpl::actualStorageLocation() const
|
||||
|
||||
bool TorrentHandleImpl::isAutoManaged() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.auto_managed;
|
||||
#else
|
||||
return static_cast<bool>(m_nativeStatus.flags & lt::torrent_flags::auto_managed);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TorrentHandleImpl::setAutoManaged(const bool enable)
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
m_nativeHandle.auto_managed(enable);
|
||||
#else
|
||||
if (enable)
|
||||
m_nativeHandle.set_flags(lt::torrent_flags::auto_managed);
|
||||
else
|
||||
m_nativeHandle.unset_flags(lt::torrent_flags::auto_managed);
|
||||
#endif
|
||||
}
|
||||
|
||||
QVector<TrackerEntry> TorrentHandleImpl::trackers() const
|
||||
@@ -526,22 +501,14 @@ void TorrentHandleImpl::clearPeers()
|
||||
bool TorrentHandleImpl::connectPeer(const PeerAddress &peerAddress)
|
||||
{
|
||||
lt::error_code ec;
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const lt::address addr = lt::address::from_string(peerAddress.ip.toString().toStdString(), ec);
|
||||
#else
|
||||
const lt::address addr = lt::make_address(peerAddress.ip.toString().toStdString(), ec);
|
||||
#endif
|
||||
if (ec) return false;
|
||||
|
||||
const lt::tcp::endpoint endpoint(addr, peerAddress.port);
|
||||
try {
|
||||
m_nativeHandle.connect_peer(endpoint);
|
||||
}
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
catch (const boost::system::system_error &err) {
|
||||
#else
|
||||
catch (const lt::system_error &err) {
|
||||
#endif
|
||||
LogMsg(tr("Failed to add peer \"%1\" to torrent \"%2\". Reason: %3")
|
||||
.arg(peerAddress.toString(), name(), QString::fromLocal8Bit(err.what())), Log::WARNING);
|
||||
return false;
|
||||
@@ -699,16 +666,12 @@ QStringList TorrentHandleImpl::absoluteFilePaths() const
|
||||
|
||||
QVector<DownloadPriority> TorrentHandleImpl::filePriorities() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const std::vector<LTDownloadPriority> fp = m_nativeHandle.file_priorities();
|
||||
#else
|
||||
const std::vector<LTDownloadPriority> fp = m_nativeHandle.get_file_priorities();
|
||||
#endif
|
||||
const std::vector<lt::download_priority_t> fp = m_nativeHandle.get_file_priorities();
|
||||
|
||||
QVector<DownloadPriority> ret;
|
||||
std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](LTDownloadPriority priority)
|
||||
std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](lt::download_priority_t priority)
|
||||
{
|
||||
return static_cast<DownloadPriority>(static_cast<LTUnderlyingType<LTDownloadPriority>>(priority));
|
||||
return static_cast<DownloadPriority>(static_cast<LTUnderlyingType<lt::download_priority_t>>(priority));
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
@@ -720,12 +683,8 @@ TorrentInfo TorrentHandleImpl::info() const
|
||||
|
||||
bool TorrentHandleImpl::isPaused() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return (m_nativeStatus.paused && !isAutoManaged());
|
||||
#else
|
||||
return ((m_nativeStatus.flags & lt::torrent_flags::paused)
|
||||
&& !isAutoManaged());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TorrentHandleImpl::isResumed() const
|
||||
@@ -735,12 +694,8 @@ bool TorrentHandleImpl::isResumed() const
|
||||
|
||||
bool TorrentHandleImpl::isQueued() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return (m_nativeStatus.paused && isAutoManaged());
|
||||
#else
|
||||
return ((m_nativeStatus.flags & lt::torrent_flags::paused)
|
||||
&& isAutoManaged());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TorrentHandleImpl::isChecking() const
|
||||
@@ -818,21 +773,13 @@ bool TorrentHandleImpl::isSeed() const
|
||||
|
||||
bool TorrentHandleImpl::isForced() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return (!m_nativeStatus.paused && !isAutoManaged());
|
||||
#else
|
||||
return (!(m_nativeStatus.flags & lt::torrent_flags::paused)
|
||||
&& !isAutoManaged());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TorrentHandleImpl::isSequentialDownload() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.sequential_download;
|
||||
#else
|
||||
return static_cast<bool>(m_nativeStatus.flags & lt::torrent_flags::sequential_download);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TorrentHandleImpl::hasFirstLastPiecePriority() const
|
||||
@@ -840,19 +787,15 @@ bool TorrentHandleImpl::hasFirstLastPiecePriority() const
|
||||
if (!hasMetadata())
|
||||
return m_needsToSetFirstLastPiecePriority;
|
||||
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const std::vector<LTDownloadPriority> filePriorities = nativeHandle().file_priorities();
|
||||
#else
|
||||
const std::vector<LTDownloadPriority> filePriorities = nativeHandle().get_file_priorities();
|
||||
#endif
|
||||
const std::vector<lt::download_priority_t> filePriorities = nativeHandle().get_file_priorities();
|
||||
for (int i = 0; i < static_cast<int>(filePriorities.size()); ++i) {
|
||||
if (filePriorities[i] <= LTDownloadPriority {0})
|
||||
if (filePriorities[i] <= lt::download_priority_t {0})
|
||||
continue;
|
||||
|
||||
const TorrentInfo::PieceRange extremities = info().filePieces(i);
|
||||
const LTDownloadPriority firstPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.first()});
|
||||
const LTDownloadPriority lastPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.last()});
|
||||
return ((firstPiecePrio == LTDownloadPriority {7}) && (lastPiecePrio == LTDownloadPriority {7}));
|
||||
const lt::download_priority_t firstPiecePrio = nativeHandle().piece_priority(lt::piece_index_t {extremities.first()});
|
||||
const lt::download_priority_t lastPiecePrio = nativeHandle().piece_priority(lt::piece_index_t {extremities.last()});
|
||||
return ((firstPiecePrio == lt::download_priority_t {7}) && (lastPiecePrio == lt::download_priority_t {7}));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -931,20 +874,16 @@ bool TorrentHandleImpl::hasError() const
|
||||
|
||||
bool TorrentHandleImpl::hasFilteredPieces() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const std::vector<LTDownloadPriority> pp = m_nativeHandle.piece_priorities();
|
||||
#else
|
||||
const std::vector<LTDownloadPriority> pp = m_nativeHandle.get_piece_priorities();
|
||||
#endif
|
||||
return std::any_of(pp.cbegin(), pp.cend(), [](const LTDownloadPriority priority)
|
||||
const std::vector<lt::download_priority_t> pp = m_nativeHandle.get_piece_priorities();
|
||||
return std::any_of(pp.cbegin(), pp.cend(), [](const lt::download_priority_t priority)
|
||||
{
|
||||
return (priority == LTDownloadPriority {0});
|
||||
return (priority == lt::download_priority_t {0});
|
||||
});
|
||||
}
|
||||
|
||||
int TorrentHandleImpl::queuePosition() const
|
||||
{
|
||||
if (m_nativeStatus.queue_position < LTQueuePosition {0}) return 0;
|
||||
if (m_nativeStatus.queue_position < lt::queue_position_t {0}) return 0;
|
||||
|
||||
return static_cast<int>(m_nativeStatus.queue_position) + 1;
|
||||
}
|
||||
@@ -966,29 +905,17 @@ qlonglong TorrentHandleImpl::totalUpload() const
|
||||
|
||||
qlonglong TorrentHandleImpl::activeTime() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.active_time;
|
||||
#else
|
||||
return lt::total_seconds(m_nativeStatus.active_duration);
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong TorrentHandleImpl::finishedTime() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.finished_time;
|
||||
#else
|
||||
return lt::total_seconds(m_nativeStatus.finished_duration);
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong TorrentHandleImpl::seedingTime() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.seeding_time;
|
||||
#else
|
||||
return lt::total_seconds(m_nativeStatus.seeding_duration);
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong TorrentHandleImpl::eta() const
|
||||
@@ -1031,11 +958,7 @@ qlonglong TorrentHandleImpl::eta() const
|
||||
|
||||
QVector<qreal> TorrentHandleImpl::filesProgress() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
std::vector<boost::int64_t> fp;
|
||||
#else
|
||||
std::vector<int64_t> fp;
|
||||
#endif
|
||||
m_nativeHandle.file_progress(fp, lt::torrent_handle::piece_granularity);
|
||||
|
||||
const int count = static_cast<int>(fp.size());
|
||||
@@ -1113,24 +1036,16 @@ QDateTime TorrentHandleImpl::completedTime() const
|
||||
|
||||
qlonglong TorrentHandleImpl::timeSinceUpload() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.time_since_upload;
|
||||
#else
|
||||
if (m_nativeStatus.last_upload.time_since_epoch().count() == 0)
|
||||
return -1;
|
||||
return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_upload);
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong TorrentHandleImpl::timeSinceDownload() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.time_since_download;
|
||||
#else
|
||||
if (m_nativeStatus.last_download.time_since_epoch().count() == 0)
|
||||
return -1;
|
||||
return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_download);
|
||||
#endif
|
||||
}
|
||||
|
||||
qlonglong TorrentHandleImpl::timeSinceActivity() const
|
||||
@@ -1154,11 +1069,7 @@ int TorrentHandleImpl::uploadLimit() const
|
||||
|
||||
bool TorrentHandleImpl::superSeeding() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
return m_nativeStatus.super_seeding;
|
||||
#else
|
||||
return static_cast<bool>(m_nativeStatus.flags & lt::torrent_flags::super_seeding);
|
||||
#endif
|
||||
}
|
||||
|
||||
QVector<PeerInfo> TorrentHandleImpl::peers() const
|
||||
@@ -1177,7 +1088,7 @@ QBitArray TorrentHandleImpl::pieces() const
|
||||
{
|
||||
QBitArray result(m_nativeStatus.pieces.size());
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
if (m_nativeStatus.pieces[LTPieceIndex {i}])
|
||||
if (m_nativeStatus.pieces[lt::piece_index_t {i}])
|
||||
result.setBit(i, true);
|
||||
}
|
||||
return result;
|
||||
@@ -1191,11 +1102,7 @@ QBitArray TorrentHandleImpl::downloadingPieces() const
|
||||
m_nativeHandle.get_download_queue(queue);
|
||||
|
||||
for (const lt::partial_piece_info &info : queue)
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
result.setBit(info.piece_index);
|
||||
#else
|
||||
result.setBit(static_cast<LTUnderlyingType<LTPieceIndex>>(info.piece_index));
|
||||
#endif
|
||||
result.setBit(static_cast<LTUnderlyingType<lt::piece_index_t>>(info.piece_index));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1231,19 +1138,11 @@ int TorrentHandleImpl::maxSeedingTime() const
|
||||
|
||||
qreal TorrentHandleImpl::realRatio() const
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const boost::int64_t upload = m_nativeStatus.all_time_upload;
|
||||
// special case for a seeder who lost its stats, also assume nobody will import a 99% done torrent
|
||||
const boost::int64_t download = (m_nativeStatus.all_time_download < (m_nativeStatus.total_done * 0.01))
|
||||
? m_nativeStatus.total_done
|
||||
: m_nativeStatus.all_time_download;
|
||||
#else
|
||||
const int64_t upload = m_nativeStatus.all_time_upload;
|
||||
// special case for a seeder who lost its stats, also assume nobody will import a 99% done torrent
|
||||
const int64_t download = (m_nativeStatus.all_time_download < (m_nativeStatus.total_done * 0.01))
|
||||
? m_nativeStatus.total_done
|
||||
: m_nativeStatus.all_time_download;
|
||||
#endif
|
||||
|
||||
if (download == 0)
|
||||
return (upload == 0) ? 0 : MAX_RATIO;
|
||||
@@ -1365,10 +1264,6 @@ void TorrentHandleImpl::forceRecheck()
|
||||
|
||||
void TorrentHandleImpl::setSequentialDownload(const bool enable)
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
m_nativeHandle.set_sequential_download(enable);
|
||||
m_nativeStatus.sequential_download = enable; // prevent return cached value
|
||||
#else
|
||||
if (enable) {
|
||||
m_nativeHandle.set_flags(lt::torrent_flags::sequential_download);
|
||||
m_nativeStatus.flags |= lt::torrent_flags::sequential_download; // prevent return cached value
|
||||
@@ -1377,7 +1272,6 @@ void TorrentHandleImpl::setSequentialDownload(const bool enable)
|
||||
m_nativeHandle.unset_flags(lt::torrent_flags::sequential_download);
|
||||
m_nativeStatus.flags &= ~lt::torrent_flags::sequential_download; // prevent return cached value
|
||||
}
|
||||
#endif
|
||||
|
||||
saveResumeData();
|
||||
}
|
||||
@@ -1396,24 +1290,19 @@ void TorrentHandleImpl::setFirstLastPiecePriorityImpl(const bool enabled, const
|
||||
return;
|
||||
}
|
||||
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const std::vector<LTDownloadPriority> filePriorities = !updatedFilePrio.isEmpty() ? toLTDownloadPriorities(updatedFilePrio)
|
||||
: nativeHandle().file_priorities();
|
||||
std::vector<LTDownloadPriority> piecePriorities = nativeHandle().piece_priorities();
|
||||
#else
|
||||
const std::vector<LTDownloadPriority> filePriorities = !updatedFilePrio.isEmpty() ? toLTDownloadPriorities(updatedFilePrio)
|
||||
const std::vector<lt::download_priority_t> filePriorities = !updatedFilePrio.isEmpty() ? toLTDownloadPriorities(updatedFilePrio)
|
||||
: nativeHandle().get_file_priorities();
|
||||
std::vector<LTDownloadPriority> piecePriorities = nativeHandle().get_piece_priorities();
|
||||
#endif
|
||||
std::vector<lt::download_priority_t> piecePriorities = nativeHandle().get_piece_priorities();
|
||||
|
||||
// Updating file priorities is an async operation in libtorrent, when we just updated it and immediately query it
|
||||
// we might get the old/wrong values, so we rely on `updatedFilePrio` in this case.
|
||||
for (int index = 0; index < static_cast<int>(filePriorities.size()); ++index) {
|
||||
const LTDownloadPriority filePrio = filePriorities[index];
|
||||
if (filePrio <= LTDownloadPriority {0})
|
||||
const lt::download_priority_t filePrio = filePriorities[index];
|
||||
if (filePrio <= lt::download_priority_t {0})
|
||||
continue;
|
||||
|
||||
// Determine the priority to set
|
||||
const LTDownloadPriority newPrio = enabled ? LTDownloadPriority {7} : filePrio;
|
||||
const lt::download_priority_t newPrio = enabled ? lt::download_priority_t {7} : filePrio;
|
||||
const TorrentInfo::PieceRange extremities = info().filePieces(index);
|
||||
|
||||
// worst case: AVI index = 1% of total file size (at the end of the file)
|
||||
@@ -1474,9 +1363,9 @@ void TorrentHandleImpl::moveStorage(const QString &newPath, const MoveStorageMod
|
||||
|
||||
void TorrentHandleImpl::renameFile(const int index, const QString &name)
|
||||
{
|
||||
m_oldPath[LTFileIndex {index}].push_back(filePath(index));
|
||||
m_oldPath[lt::file_index_t {index}].push_back(filePath(index));
|
||||
++m_renameCount;
|
||||
m_nativeHandle.rename_file(LTFileIndex {index}, Utils::Fs::toNativePath(name).toStdString());
|
||||
m_nativeHandle.rename_file(lt::file_index_t {index}, Utils::Fs::toNativePath(name).toStdString());
|
||||
}
|
||||
|
||||
void TorrentHandleImpl::handleStateUpdate(const lt::torrent_status &nativeStatus)
|
||||
@@ -1611,17 +1500,10 @@ void TorrentHandleImpl::handleTorrentResumedAlert(const lt::torrent_resumed_aler
|
||||
|
||||
void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
const bool useDummyResumeData = !(p && p->resume_data);
|
||||
auto resumeDataPtr = std::make_shared<lt::entry>(useDummyResumeData
|
||||
? lt::entry {}
|
||||
: *(p->resume_data));
|
||||
#else
|
||||
const bool useDummyResumeData = !p;
|
||||
auto resumeDataPtr = std::make_shared<lt::entry>(useDummyResumeData
|
||||
? lt::entry {}
|
||||
: lt::write_resume_data(p->params));
|
||||
#endif
|
||||
lt::entry &resumeData = *resumeDataPtr;
|
||||
|
||||
updateStatus();
|
||||
@@ -1653,11 +1535,7 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale
|
||||
resumeData["qBt-queuePosition"] = (static_cast<int>(nativeHandle().queue_position()) + 1); // qBt starts queue at 1
|
||||
resumeData["qBt-hasRootFolder"] = m_hasRootFolder;
|
||||
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
if (m_nativeStatus.stop_when_ready) {
|
||||
#else
|
||||
if (m_nativeStatus.flags & lt::torrent_flags::stop_when_ready) {
|
||||
#endif
|
||||
// We need to redefine these values when torrent starting/rechecking
|
||||
// in "paused" state since native values can be logically wrong
|
||||
// (torrent can be not paused and auto_managed when it is checking).
|
||||
@@ -1746,7 +1624,7 @@ void TorrentHandleImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
||||
void TorrentHandleImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p)
|
||||
{
|
||||
LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"")
|
||||
.arg(name(), filePath(static_cast<LTUnderlyingType<LTFileIndex>>(p->index))
|
||||
.arg(name(), filePath(static_cast<LTUnderlyingType<lt::file_index_t>>(p->index))
|
||||
, QString::fromLocal8Bit(p->error.message().c_str())), Log::WARNING);
|
||||
|
||||
m_oldPath[p->index].removeFirst();
|
||||
@@ -1769,12 +1647,12 @@ void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert
|
||||
|
||||
qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name()));
|
||||
if (m_session->isAppendExtensionEnabled()) {
|
||||
QString name = filePath(static_cast<LTUnderlyingType<LTFileIndex>>(p->index));
|
||||
QString name = filePath(static_cast<LTUnderlyingType<lt::file_index_t>>(p->index));
|
||||
if (name.endsWith(QB_EXT)) {
|
||||
const QString oldName = name;
|
||||
name.chop(QB_EXT.size());
|
||||
qDebug("Renaming %s to %s", qUtf8Printable(oldName), qUtf8Printable(name));
|
||||
renameFile(static_cast<LTUnderlyingType<LTFileIndex>>(p->index), name);
|
||||
renameFile(static_cast<LTUnderlyingType<lt::file_index_t>>(p->index), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2027,14 +1905,10 @@ void TorrentHandleImpl::setDownloadLimit(const int limit)
|
||||
|
||||
void TorrentHandleImpl::setSuperSeeding(const bool enable)
|
||||
{
|
||||
#if (LIBTORRENT_VERSION_NUM < 10200)
|
||||
m_nativeHandle.super_seeding(enable);
|
||||
#else
|
||||
if (enable)
|
||||
m_nativeHandle.set_flags(lt::torrent_flags::super_seeding);
|
||||
else
|
||||
m_nativeHandle.unset_flags(lt::torrent_flags::super_seeding);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TorrentHandleImpl::flushCache() const
|
||||
|
||||
Reference in New Issue
Block a user