mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
parent
7982f66fa6
commit
0729c9a2f8
4 changed files with 186 additions and 181 deletions
|
@ -5845,20 +5845,41 @@ void SessionImpl::handleAlert(const lt::alert *alert)
|
|||
{
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
case lt::file_prio_alert::alert_type:
|
||||
handleFilePrioAlert(static_cast<const lt::file_prio_alert *>(alert));
|
||||
break;
|
||||
#endif
|
||||
case lt::file_renamed_alert::alert_type:
|
||||
handleFileRenamedAlert(static_cast<const lt::file_renamed_alert *>(alert));
|
||||
break;
|
||||
case lt::file_rename_failed_alert::alert_type:
|
||||
handleFileRenameFailedAlert(static_cast<const lt::file_rename_failed_alert *>(alert));
|
||||
break;
|
||||
case lt::file_completed_alert::alert_type:
|
||||
handleFileCompletedAlert(static_cast<const lt::file_completed_alert *>(alert));
|
||||
break;
|
||||
case lt::file_error_alert::alert_type:
|
||||
handleFileErrorAlert(static_cast<const lt::file_error_alert *>(alert));
|
||||
break;
|
||||
case lt::torrent_finished_alert::alert_type:
|
||||
handleTorrentFinishedAlert(static_cast<const lt::torrent_finished_alert *>(alert));
|
||||
break;
|
||||
case lt::save_resume_data_alert::alert_type:
|
||||
handleSaveResumeDataAlert(static_cast<const lt::save_resume_data_alert *>(alert));
|
||||
break;
|
||||
case lt::save_resume_data_failed_alert::alert_type:
|
||||
case lt::torrent_paused_alert::alert_type:
|
||||
case lt::torrent_resumed_alert::alert_type:
|
||||
case lt::fastresume_rejected_alert::alert_type:
|
||||
case lt::torrent_checked_alert::alert_type:
|
||||
handleSaveResumeDataFailedAlert(static_cast<const lt::save_resume_data_failed_alert *>(alert));
|
||||
break;
|
||||
case lt::metadata_received_alert::alert_type:
|
||||
handleMetadataReceivedAlert(static_cast<const lt::metadata_received_alert *>(alert));
|
||||
break;
|
||||
case lt::fastresume_rejected_alert::alert_type:
|
||||
handleFastResumeRejectedAlert(static_cast<const lt::fastresume_rejected_alert *>(alert));
|
||||
break;
|
||||
case lt::torrent_checked_alert::alert_type:
|
||||
handleTorrentCheckedAlert(static_cast<const lt::torrent_checked_alert *>(alert));
|
||||
break;
|
||||
case lt::performance_alert::alert_type:
|
||||
dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(alert));
|
||||
handlePerformanceAlert(static_cast<const lt::performance_alert *>(alert));
|
||||
break;
|
||||
case lt::state_update_alert::alert_type:
|
||||
handleStateUpdateAlert(static_cast<const lt::state_update_alert *>(alert));
|
||||
|
@ -5875,9 +5896,6 @@ void SessionImpl::handleAlert(const lt::alert *alert)
|
|||
case lt::tracker_warning_alert::alert_type:
|
||||
handleTrackerAlert(static_cast<const lt::tracker_alert *>(alert));
|
||||
break;
|
||||
case lt::file_error_alert::alert_type:
|
||||
handleFileErrorAlert(static_cast<const lt::file_error_alert *>(alert));
|
||||
break;
|
||||
case lt::add_torrent_alert::alert_type:
|
||||
handleAddTorrentAlert(static_cast<const lt::add_torrent_alert *>(alert));
|
||||
break;
|
||||
|
@ -5945,41 +5963,6 @@ void SessionImpl::handleAlert(const lt::alert *alert)
|
|||
}
|
||||
}
|
||||
|
||||
void SessionImpl::dispatchTorrentAlert(const lt::torrent_alert *alert)
|
||||
{
|
||||
// The torrent can be deleted between the time the resume data was requested and
|
||||
// the time we received the appropriate alert. We have to decrease `m_numResumeData` anyway,
|
||||
// so we do this before checking for an existing torrent.
|
||||
if ((alert->type() == lt::save_resume_data_alert::alert_type)
|
||||
|| (alert->type() == lt::save_resume_data_failed_alert::alert_type))
|
||||
{
|
||||
--m_numResumeData;
|
||||
}
|
||||
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
if (!torrent && (alert->type() == lt::metadata_received_alert::alert_type))
|
||||
{
|
||||
const InfoHash infoHash = getInfoHash(alert->handle);
|
||||
if (infoHash.isHybrid())
|
||||
torrent = m_torrents.value(TorrentID::fromSHA1Hash(infoHash.v1()));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (torrent)
|
||||
{
|
||||
torrent->handleAlert(alert);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (alert->type())
|
||||
{
|
||||
case lt::metadata_received_alert::alert_type:
|
||||
handleMetadataReceivedAlert(static_cast<const lt::metadata_received_alert *>(alert));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TorrentImpl *SessionImpl::createTorrent(const lt::torrent_handle &nativeHandle, const LoadTorrentParams ¶ms)
|
||||
{
|
||||
auto *const torrent = new TorrentImpl(this, nativeHandle, params);
|
||||
|
@ -6040,6 +6023,19 @@ void SessionImpl::handleTorrentNeedCertAlert(const lt::torrent_need_cert_alert *
|
|||
|
||||
void SessionImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *alert)
|
||||
{
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
if (!torrent && (alert->type() == lt::metadata_received_alert::alert_type))
|
||||
{
|
||||
const InfoHash infoHash = getInfoHash(alert->handle);
|
||||
if (infoHash.isHybrid())
|
||||
torrent = m_torrents.value(TorrentID::fromSHA1Hash(infoHash.v1()));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (torrent)
|
||||
return torrent->handleMetadataReceived();
|
||||
|
||||
const InfoHash infoHash = getInfoHash(alert->handle);
|
||||
const TorrentID torrentID = infoHash.toTorrentID();
|
||||
|
||||
|
@ -6072,10 +6068,10 @@ void SessionImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert
|
|||
void SessionImpl::handleFileErrorAlert(const lt::file_error_alert *alert)
|
||||
{
|
||||
TorrentImpl *const torrent = getTorrent(alert->handle);
|
||||
if (!torrent)
|
||||
if (!torrent) [[unlikely]]
|
||||
return;
|
||||
|
||||
torrent->handleAlert(alert);
|
||||
torrent->handleFileError({.error = alert->error, .operation = alert->op});
|
||||
|
||||
const TorrentID id = torrent->id();
|
||||
if (!m_recentErroredTorrents.contains(id))
|
||||
|
@ -6467,8 +6463,106 @@ void SessionImpl::handleTorrentConflictAlert(const lt::torrent_conflict_alert *a
|
|||
if (!torrent1 || !torrent2)
|
||||
emit metadataDownloaded(TorrentInfo(*alert->metadata));
|
||||
}
|
||||
|
||||
void SessionImpl::handleFilePrioAlert(const lt::file_prio_alert *alert)
|
||||
{
|
||||
if (TorrentImpl *torrent = getTorrent(alert->handle)) [[likely]]
|
||||
torrent->deferredRequestResumeData();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SessionImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *alert)
|
||||
{
|
||||
if (TorrentImpl *torrent = getTorrent(alert->handle)) [[likely]]
|
||||
torrent->handleTorrentChecked();
|
||||
}
|
||||
|
||||
void SessionImpl::handleTorrentFinishedAlert([[maybe_unused]] const lt::torrent_finished_alert *alert)
|
||||
{
|
||||
if (TorrentImpl *torrent = getTorrent(alert->handle)) [[likely]]
|
||||
torrent->handleTorrentFinished();
|
||||
}
|
||||
|
||||
void SessionImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *alert)
|
||||
{
|
||||
// The torrent can be deleted between the time the resume data was requested and
|
||||
// the time we received the appropriate alert. We have to decrease `m_numResumeData` anyway,
|
||||
// so we do this before checking for an existing torrent.
|
||||
--m_numResumeData;
|
||||
|
||||
if (TorrentImpl *torrent = getTorrent(alert->handle)) [[likely]]
|
||||
torrent->handleSaveResumeData(alert->params); // TODO: Try to move `alert->params`
|
||||
}
|
||||
|
||||
void SessionImpl::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *alert)
|
||||
{
|
||||
// The torrent can be deleted between the time the resume data was requested and
|
||||
// the time we received the appropriate alert. We have to decrease `m_numResumeData` anyway,
|
||||
// so we do this before checking for an existing torrent.
|
||||
--m_numResumeData;
|
||||
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
if (!torrent) [[unlikely]]
|
||||
return;
|
||||
|
||||
if (alert->error != lt::errors::resume_data_not_modified)
|
||||
{
|
||||
LogMsg(tr("Generate resume data failed. Torrent: \"%1\". Reason: \"%2\"")
|
||||
.arg(torrent->name(), Utils::String::fromLocal8Bit(alert->error.message())), Log::CRITICAL);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *alert)
|
||||
{
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
if (!torrent) [[unlikely]]
|
||||
return;
|
||||
|
||||
torrent->handleFastResumeRejected();
|
||||
LogMsg(tr("Failed to restore torrent. Files were probably moved or storage isn't accessible. Torrent: \"%1\". Reason: \"%2\"")
|
||||
.arg(torrent->name(), QString::fromStdString(alert->message())), Log::WARNING);
|
||||
}
|
||||
|
||||
void SessionImpl::handleFileRenamedAlert(const lt::file_renamed_alert *alert)
|
||||
{
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
if (!torrent) [[unlikely]]
|
||||
return;
|
||||
|
||||
const Path newFilePath {QString::fromUtf8(alert->new_name())};
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
const Path oldFilePath {QString::fromUtf8(alert->old_name())};
|
||||
#else
|
||||
const Path oldFilePath;
|
||||
#endif
|
||||
torrent->handleFileRenamed(alert->index, newFilePath, oldFilePath);
|
||||
}
|
||||
|
||||
void SessionImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *alert)
|
||||
{
|
||||
TorrentImpl *torrent = getTorrent(alert->handle);
|
||||
if (!torrent) [[unlikely]]
|
||||
return;
|
||||
|
||||
torrent->handleFileRenameFailed(alert->index);
|
||||
|
||||
LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"")
|
||||
.arg(torrent->name(), torrent->filePath(torrent->fileIndexFromNative(alert->index)).toString()
|
||||
, Utils::String::fromLocal8Bit(alert->error.message())), Log::WARNING);
|
||||
}
|
||||
|
||||
void SessionImpl::handleFileCompletedAlert(const lt::file_completed_alert *alert)
|
||||
{
|
||||
if (TorrentImpl *torrent = getTorrent(alert->handle)) [[likely]]
|
||||
torrent->handleFileCompleted(alert->index);
|
||||
}
|
||||
|
||||
void SessionImpl::handlePerformanceAlert(const lt::performance_alert *alert) const
|
||||
{
|
||||
LogMsg((tr("Performance alert: %1. More info: %2").arg(QString::fromStdString(alert->message())
|
||||
, u"https://libtorrent.org/reference-Alerts.html#enum-performance-warning-t"_s)), Log::INFO);
|
||||
}
|
||||
|
||||
void SessionImpl::saveStatistics() const
|
||||
{
|
||||
if (!m_isStatisticsDirty)
|
||||
|
|
|
@ -580,7 +580,6 @@ namespace BitTorrent
|
|||
void exportTorrentFile(const Torrent *torrent, const Path &folderPath);
|
||||
|
||||
void handleAlert(const lt::alert *alert);
|
||||
void dispatchTorrentAlert(const lt::torrent_alert *alert);
|
||||
void handleAddTorrentAlert(const lt::add_torrent_alert *alert);
|
||||
void handleStateUpdateAlert(const lt::state_update_alert *alert);
|
||||
void handleMetadataReceivedAlert(const lt::metadata_received_alert *alert);
|
||||
|
@ -607,7 +606,17 @@ namespace BitTorrent
|
|||
void handleTrackerAlert(const lt::tracker_alert *alert);
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
void handleTorrentConflictAlert(const lt::torrent_conflict_alert *alert);
|
||||
void handleFilePrioAlert(const lt::file_prio_alert *alert);
|
||||
#endif
|
||||
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *alert);
|
||||
void handleFileCompletedAlert(const lt::file_completed_alert *alert);
|
||||
void handleFileRenamedAlert(const lt::file_renamed_alert *alert);
|
||||
void handleFileRenameFailedAlert(const lt::file_rename_failed_alert *alert);
|
||||
void handlePerformanceAlert(const lt::performance_alert *alert) const;
|
||||
void handleSaveResumeDataAlert(const lt::save_resume_data_alert *alert);
|
||||
void handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *alert);
|
||||
void handleTorrentCheckedAlert(const lt::torrent_checked_alert *alert);
|
||||
void handleTorrentFinishedAlert(const lt::torrent_finished_alert *alert);
|
||||
|
||||
TorrentImpl *createTorrent(const lt::torrent_handle &nativeHandle, const LoadTorrentParams ¶ms);
|
||||
TorrentImpl *getTorrent(const lt::torrent_handle &nativeHandle) const;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#endif
|
||||
|
||||
#include <libtorrent/address.hpp>
|
||||
#include <libtorrent/alert_types.hpp>
|
||||
#include <libtorrent/create_torrent.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
#include <libtorrent/storage_defs.hpp>
|
||||
|
@ -2023,7 +2022,7 @@ void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStora
|
|||
}
|
||||
}
|
||||
|
||||
void TorrentImpl::handleTorrentCheckedAlert([[maybe_unused]] const lt::torrent_checked_alert *p)
|
||||
void TorrentImpl::handleTorrentChecked()
|
||||
{
|
||||
if (!hasMetadata())
|
||||
{
|
||||
|
@ -2066,7 +2065,7 @@ void TorrentImpl::handleTorrentCheckedAlert([[maybe_unused]] const lt::torrent_c
|
|||
});
|
||||
}
|
||||
|
||||
void TorrentImpl::handleTorrentFinishedAlert([[maybe_unused]] const lt::torrent_finished_alert *p)
|
||||
void TorrentImpl::handleTorrentFinished()
|
||||
{
|
||||
m_hasMissingFiles = false;
|
||||
if (m_hasFinishedStatus)
|
||||
|
@ -2096,17 +2095,9 @@ void TorrentImpl::handleTorrentFinishedAlert([[maybe_unused]] const lt::torrent_
|
|||
});
|
||||
}
|
||||
|
||||
void TorrentImpl::handleTorrentPausedAlert([[maybe_unused]] const lt::torrent_paused_alert *p)
|
||||
void TorrentImpl::handleSaveResumeData(lt::add_torrent_params params)
|
||||
{
|
||||
}
|
||||
|
||||
void TorrentImpl::handleTorrentResumedAlert([[maybe_unused]] const lt::torrent_resumed_alert *p)
|
||||
{
|
||||
}
|
||||
|
||||
void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
|
||||
{
|
||||
if (m_ltAddTorrentParams.url_seeds != p->params.url_seeds)
|
||||
if (m_ltAddTorrentParams.url_seeds != params.url_seeds)
|
||||
{
|
||||
// URL seed list have been changed by libtorrent for some reason, so we need to update cached one.
|
||||
// Unfortunately, URL seed list containing in "resume data" is generated according to different rules
|
||||
|
@ -2114,12 +2105,12 @@ void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
|
|||
fetchURLSeeds().then(this, [this](const QList<QUrl> &urlSeeds) { m_urlSeeds = urlSeeds; });
|
||||
}
|
||||
|
||||
if ((m_maintenanceJob == MaintenanceJob::HandleMetadata) && p->params.ti)
|
||||
if ((m_maintenanceJob == MaintenanceJob::HandleMetadata) && params.ti)
|
||||
{
|
||||
Q_ASSERT(m_indexMap.isEmpty());
|
||||
|
||||
const auto isSeedMode = static_cast<bool>(m_ltAddTorrentParams.flags & lt::torrent_flags::seed_mode);
|
||||
m_ltAddTorrentParams = p->params;
|
||||
m_ltAddTorrentParams = std::move(params);
|
||||
if (isSeedMode)
|
||||
m_ltAddTorrentParams.flags |= lt::torrent_flags::seed_mode;
|
||||
|
||||
|
@ -2167,11 +2158,11 @@ void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
|
|||
}
|
||||
else
|
||||
{
|
||||
prepareResumeData(p->params);
|
||||
prepareResumeData(std::move(params));
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentImpl::prepareResumeData(const lt::add_torrent_params ¶ms)
|
||||
void TorrentImpl::prepareResumeData(lt::add_torrent_params params)
|
||||
{
|
||||
{
|
||||
decltype(params.have_pieces) havePieces;
|
||||
|
@ -2195,7 +2186,7 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params ¶ms)
|
|||
}
|
||||
|
||||
// Update recent resume data
|
||||
m_ltAddTorrentParams = params;
|
||||
m_ltAddTorrentParams = std::move(params);
|
||||
|
||||
if (needPreserveProgress)
|
||||
{
|
||||
|
@ -2237,30 +2228,17 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params ¶ms)
|
|||
m_session->handleTorrentResumeDataReady(this, resumeData);
|
||||
}
|
||||
|
||||
void TorrentImpl::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p)
|
||||
{
|
||||
if (p->error != lt::errors::resume_data_not_modified)
|
||||
{
|
||||
LogMsg(tr("Generate resume data failed. Torrent: \"%1\". Reason: \"%2\"")
|
||||
.arg(name(), Utils::String::fromLocal8Bit(p->error.message())), Log::CRITICAL);
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p)
|
||||
void TorrentImpl::handleFastResumeRejected()
|
||||
{
|
||||
// Files were probably moved or storage isn't accessible
|
||||
m_hasMissingFiles = true;
|
||||
LogMsg(tr("Failed to restore torrent. Files were probably moved or storage isn't accessible. Torrent: \"%1\". Reason: \"%2\"")
|
||||
.arg(name(), QString::fromStdString(p->message())), Log::WARNING);
|
||||
}
|
||||
|
||||
void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
||||
void TorrentImpl::handleFileRenamed(const lt::file_index_t nativeFileIndex, const Path &newActualFilePath, const Path &oldActualFilePath)
|
||||
{
|
||||
const int fileIndex = m_indexMap.value(p->index, -1);
|
||||
const int fileIndex = fileIndexFromNative(nativeFileIndex);
|
||||
Q_ASSERT(fileIndex >= 0);
|
||||
|
||||
const Path newActualFilePath {QString::fromUtf8(p->new_name())};
|
||||
|
||||
const Path oldFilePath = m_filePaths.at(fileIndex);
|
||||
const Path newFilePath = makeUserPath(newActualFilePath);
|
||||
|
||||
|
@ -2270,11 +2248,6 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
|||
if (oldFilePath.data() == newFilePath.data())
|
||||
{
|
||||
// Remove empty ".unwanted" folders
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
const Path oldActualFilePath {QString::fromUtf8(p->old_name())};
|
||||
#else
|
||||
const Path oldActualFilePath;
|
||||
#endif
|
||||
const Path oldActualParentPath = oldActualFilePath.parentPath();
|
||||
const Path newActualParentPath = newActualFilePath.parentPath();
|
||||
if (newActualParentPath.filename() == UNWANTED_FOLDER_NAME)
|
||||
|
@ -2324,14 +2297,11 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
|||
deferredRequestResumeData();
|
||||
}
|
||||
|
||||
void TorrentImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p)
|
||||
void TorrentImpl::handleFileRenameFailed(const lt::file_index_t nativeFileIndex)
|
||||
{
|
||||
const int fileIndex = m_indexMap.value(p->index, -1);
|
||||
const int fileIndex = fileIndexFromNative(nativeFileIndex);
|
||||
Q_ASSERT(fileIndex >= 0);
|
||||
|
||||
LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"")
|
||||
.arg(name(), filePath(fileIndex).toString(), Utils::String::fromLocal8Bit(p->error.message())), Log::WARNING);
|
||||
|
||||
--m_renameCount;
|
||||
while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty())
|
||||
m_moveFinishedTriggers.takeFirst()();
|
||||
|
@ -2339,12 +2309,12 @@ void TorrentImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert
|
|||
deferredRequestResumeData();
|
||||
}
|
||||
|
||||
void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
|
||||
void TorrentImpl::handleFileCompleted(const lt::file_index_t nativeFileIndex)
|
||||
{
|
||||
if (m_maintenanceJob == MaintenanceJob::HandleMetadata)
|
||||
return;
|
||||
|
||||
const int fileIndex = m_indexMap.value(p->index, -1);
|
||||
const int fileIndex = fileIndexFromNative(nativeFileIndex);
|
||||
Q_ASSERT(fileIndex >= 0);
|
||||
|
||||
m_completedFiles.setBit(fileIndex);
|
||||
|
@ -2372,22 +2342,13 @@ void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
|
|||
}
|
||||
}
|
||||
|
||||
void TorrentImpl::handleFileErrorAlert(const lt::file_error_alert *p)
|
||||
void TorrentImpl::handleFileError(FileErrorInfo fileError)
|
||||
{
|
||||
m_lastFileError = {p->error, p->op};
|
||||
m_lastFileError = std::move(fileError);
|
||||
}
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *)
|
||||
void TorrentImpl::handleMetadataReceived()
|
||||
{
|
||||
deferredRequestResumeData();
|
||||
}
|
||||
#endif
|
||||
|
||||
void TorrentImpl::handleMetadataReceivedAlert([[maybe_unused]] const lt::metadata_received_alert *p)
|
||||
{
|
||||
qDebug("Metadata received for torrent %s.", qUtf8Printable(name()));
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
const InfoHash prevInfoHash = infoHash();
|
||||
m_infoHash = InfoHash(m_nativeHandle.info_hashes());
|
||||
|
@ -2399,12 +2360,6 @@ void TorrentImpl::handleMetadataReceivedAlert([[maybe_unused]] const lt::metadat
|
|||
deferredRequestResumeData();
|
||||
}
|
||||
|
||||
void TorrentImpl::handlePerformanceAlert(const lt::performance_alert *p) const
|
||||
{
|
||||
LogMsg((tr("Performance alert: %1. More info: %2").arg(QString::fromStdString(p->message()), u"https://libtorrent.org/reference-Alerts.html#enum-performance-warning-t"_s))
|
||||
, Log::INFO);
|
||||
}
|
||||
|
||||
void TorrentImpl::handleCategoryOptionsChanged()
|
||||
{
|
||||
if (m_useAutoTMM)
|
||||
|
@ -2427,57 +2382,6 @@ void TorrentImpl::handleUnwantedFolderToggled()
|
|||
manageActualFilePaths();
|
||||
}
|
||||
|
||||
void TorrentImpl::handleAlert(const lt::alert *a)
|
||||
{
|
||||
switch (a->type())
|
||||
{
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
case lt::file_prio_alert::alert_type:
|
||||
handleFilePrioAlert(static_cast<const lt::file_prio_alert*>(a));
|
||||
break;
|
||||
#endif
|
||||
case lt::file_renamed_alert::alert_type:
|
||||
handleFileRenamedAlert(static_cast<const lt::file_renamed_alert*>(a));
|
||||
break;
|
||||
case lt::file_rename_failed_alert::alert_type:
|
||||
handleFileRenameFailedAlert(static_cast<const lt::file_rename_failed_alert*>(a));
|
||||
break;
|
||||
case lt::file_completed_alert::alert_type:
|
||||
handleFileCompletedAlert(static_cast<const lt::file_completed_alert*>(a));
|
||||
break;
|
||||
case lt::file_error_alert::alert_type:
|
||||
handleFileErrorAlert(static_cast<const lt::file_error_alert*>(a));
|
||||
break;
|
||||
case lt::torrent_finished_alert::alert_type:
|
||||
handleTorrentFinishedAlert(static_cast<const lt::torrent_finished_alert*>(a));
|
||||
break;
|
||||
case lt::save_resume_data_alert::alert_type:
|
||||
handleSaveResumeDataAlert(static_cast<const lt::save_resume_data_alert*>(a));
|
||||
break;
|
||||
case lt::save_resume_data_failed_alert::alert_type:
|
||||
handleSaveResumeDataFailedAlert(static_cast<const lt::save_resume_data_failed_alert*>(a));
|
||||
break;
|
||||
case lt::torrent_paused_alert::alert_type:
|
||||
handleTorrentPausedAlert(static_cast<const lt::torrent_paused_alert*>(a));
|
||||
break;
|
||||
case lt::torrent_resumed_alert::alert_type:
|
||||
handleTorrentResumedAlert(static_cast<const lt::torrent_resumed_alert*>(a));
|
||||
break;
|
||||
case lt::metadata_received_alert::alert_type:
|
||||
handleMetadataReceivedAlert(static_cast<const lt::metadata_received_alert*>(a));
|
||||
break;
|
||||
case lt::fastresume_rejected_alert::alert_type:
|
||||
handleFastResumeRejectedAlert(static_cast<const lt::fastresume_rejected_alert*>(a));
|
||||
break;
|
||||
case lt::torrent_checked_alert::alert_type:
|
||||
handleTorrentCheckedAlert(static_cast<const lt::torrent_checked_alert*>(a));
|
||||
break;
|
||||
case lt::performance_alert::alert_type:
|
||||
handlePerformanceAlert(static_cast<const lt::performance_alert*>(a));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentImpl::manageActualFilePaths()
|
||||
{
|
||||
const std::shared_ptr<const lt::torrent_info> nativeInfo = nativeTorrentInfo();
|
||||
|
@ -2525,6 +2429,11 @@ lt::torrent_handle TorrentImpl::nativeHandle() const
|
|||
return m_nativeHandle;
|
||||
}
|
||||
|
||||
int TorrentImpl::fileIndexFromNative(const lt::file_index_t nativeFileIndex) const
|
||||
{
|
||||
return m_indexMap.value(nativeFileIndex, -1);
|
||||
}
|
||||
|
||||
void TorrentImpl::setMetadata(const TorrentInfo &torrentInfo)
|
||||
{
|
||||
if (hasMetadata())
|
||||
|
@ -3016,7 +2925,7 @@ void TorrentImpl::prioritizeFiles(const QList<DownloadPriority> &priorities)
|
|||
Q_ASSERT(priorities.size() == filesCount());
|
||||
|
||||
// Reset 'm_hasSeedStatus' if needed in order to react again to
|
||||
// 'torrent_finished_alert' and eg show tray notifications
|
||||
// "torrent finished" event and e.g. show tray notifications
|
||||
const QList<DownloadPriority> oldPriorities = filePriorities();
|
||||
for (int i = 0; i < oldPriorities.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -264,8 +264,18 @@ namespace BitTorrent
|
|||
// Session interface
|
||||
lt::torrent_handle nativeHandle() const;
|
||||
|
||||
void handleAlert(const lt::alert *a);
|
||||
int fileIndexFromNative(lt::file_index_t nativeFileIndex) const;
|
||||
|
||||
void handleStateUpdate(const lt::torrent_status &nativeStatus);
|
||||
void handleFastResumeRejected();
|
||||
void handleFileCompleted(lt::file_index_t nativeFileIndex);
|
||||
void handleFileError(FileErrorInfo fileError);
|
||||
void handleFileRenamed(lt::file_index_t nativeFileIndex, const Path &newActualFilePath, const Path &oldActualFilePath);
|
||||
void handleFileRenameFailed(lt::file_index_t nativeFileIndex);
|
||||
void handleMetadataReceived();
|
||||
void handleSaveResumeData(lt::add_torrent_params params);
|
||||
void handleTorrentChecked();
|
||||
void handleTorrentFinished();
|
||||
void handleQueueingModeChanged();
|
||||
void handleCategoryOptionsChanged();
|
||||
void handleAppendExtensionToggled();
|
||||
|
@ -285,23 +295,6 @@ namespace BitTorrent
|
|||
void updateProgress();
|
||||
void updateState();
|
||||
|
||||
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
|
||||
void handleFileCompletedAlert(const lt::file_completed_alert *p);
|
||||
void handleFileErrorAlert(const lt::file_error_alert *p);
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
void handleFilePrioAlert(const lt::file_prio_alert *p);
|
||||
#endif
|
||||
void handleFileRenamedAlert(const lt::file_renamed_alert *p);
|
||||
void handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p);
|
||||
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
|
||||
void handlePerformanceAlert(const lt::performance_alert *p) const;
|
||||
void handleSaveResumeDataAlert(const lt::save_resume_data_alert *p);
|
||||
void handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p);
|
||||
void handleTorrentCheckedAlert(const lt::torrent_checked_alert *p);
|
||||
void handleTorrentFinishedAlert(const lt::torrent_finished_alert *p);
|
||||
void handleTorrentPausedAlert(const lt::torrent_paused_alert *p);
|
||||
void handleTorrentResumedAlert(const lt::torrent_resumed_alert *p);
|
||||
|
||||
bool isMoveInProgress() const;
|
||||
|
||||
void setAutoManaged(bool enable);
|
||||
|
@ -314,7 +307,7 @@ namespace BitTorrent
|
|||
void manageActualFilePaths();
|
||||
void applyFirstLastPiecePriority(bool enabled);
|
||||
|
||||
void prepareResumeData(const lt::add_torrent_params ¶ms);
|
||||
void prepareResumeData(lt::add_torrent_params resumeData);
|
||||
void endReceivedMetadataHandling(const Path &savePath, const PathList &fileNames);
|
||||
void reload();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue