mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
parent
de8050701d
commit
7ebd63a60f
@ -2362,7 +2362,6 @@ void Session::generateResumeData(bool final)
|
|||||||
if (!final && !torrent->needSaveResumeData()) continue;
|
if (!final && !torrent->needSaveResumeData()) continue;
|
||||||
|
|
||||||
saveTorrentResumeData(torrent, final);
|
saveTorrentResumeData(torrent, final);
|
||||||
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3529,45 +3528,58 @@ void Session::updateSeedingLimitTimer()
|
|||||||
|
|
||||||
void Session::handleTorrentShareLimitChanged(TorrentHandle *const torrent)
|
void Session::handleTorrentShareLimitChanged(TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(torrent);
|
saveTorrentResumeData(torrent);
|
||||||
updateSeedingLimitTimer();
|
updateSeedingLimitTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::saveTorrentResumeData(TorrentHandle *const torrent, bool finalSave)
|
void Session::saveTorrentResumeData(TorrentHandle *const torrent, bool finalSave)
|
||||||
{
|
{
|
||||||
|
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));
|
||||||
torrent->saveResumeData(finalSave);
|
torrent->saveResumeData(finalSave);
|
||||||
++m_numResumeData;
|
++m_numResumeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::handleTorrentNameChanged(TorrentHandle *const torrent)
|
||||||
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
|
}
|
||||||
|
|
||||||
void Session::handleTorrentSavePathChanged(TorrentHandle *const torrent)
|
void Session::handleTorrentSavePathChanged(TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentSavePathChanged(torrent);
|
emit torrentSavePathChanged(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory)
|
void Session::handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentCategoryChanged(torrent, oldCategory);
|
emit torrentCategoryChanged(torrent, oldCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentTagAdded(TorrentHandle *const torrent, const QString &tag)
|
void Session::handleTorrentTagAdded(TorrentHandle *const torrent, const QString &tag)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentTagAdded(torrent, tag);
|
emit torrentTagAdded(torrent, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QString &tag)
|
void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QString &tag)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentTagRemoved(torrent, tag);
|
emit torrentTagRemoved(torrent, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent)
|
void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentSavingModeChanged(torrent);
|
emit torrentSavingModeChanged(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentTrackersAdded(TorrentHandle *const torrent, const QList<TrackerEntry> &newTrackers)
|
void Session::handleTorrentTrackersAdded(TorrentHandle *const torrent, const QList<TrackerEntry> &newTrackers)
|
||||||
{
|
{
|
||||||
foreach (const TrackerEntry &newTracker, newTrackers)
|
saveTorrentResumeData(torrent);
|
||||||
Logger::instance()->addMessage(tr("Tracker '%1' was added to torrent '%2'").arg(newTracker.url(), torrent->name()));
|
|
||||||
|
for (const TrackerEntry &newTracker : newTrackers)
|
||||||
|
LogMsg(tr("Tracker '%1' was added to torrent '%2'").arg(newTracker.url(), torrent->name()));
|
||||||
emit trackersAdded(torrent, newTrackers);
|
emit trackersAdded(torrent, newTrackers);
|
||||||
if (torrent->trackers().size() == newTrackers.size())
|
if (torrent->trackers().size() == newTrackers.size())
|
||||||
emit trackerlessStateChanged(torrent, false);
|
emit trackerlessStateChanged(torrent, false);
|
||||||
@ -3576,8 +3588,10 @@ void Session::handleTorrentTrackersAdded(TorrentHandle *const torrent, const QLi
|
|||||||
|
|
||||||
void Session::handleTorrentTrackersRemoved(TorrentHandle *const torrent, const QList<TrackerEntry> &deletedTrackers)
|
void Session::handleTorrentTrackersRemoved(TorrentHandle *const torrent, const QList<TrackerEntry> &deletedTrackers)
|
||||||
{
|
{
|
||||||
foreach (const TrackerEntry &deletedTracker, deletedTrackers)
|
saveTorrentResumeData(torrent);
|
||||||
Logger::instance()->addMessage(tr("Tracker '%1' was deleted from torrent '%2'").arg(deletedTracker.url(), torrent->name()));
|
|
||||||
|
for (const TrackerEntry &deletedTracker : deletedTrackers)
|
||||||
|
LogMsg(tr("Tracker '%1' was deleted from torrent '%2'").arg(deletedTracker.url(), torrent->name()));
|
||||||
emit trackersRemoved(torrent, deletedTrackers);
|
emit trackersRemoved(torrent, deletedTrackers);
|
||||||
if (torrent->trackers().size() == 0)
|
if (torrent->trackers().size() == 0)
|
||||||
emit trackerlessStateChanged(torrent, true);
|
emit trackerlessStateChanged(torrent, true);
|
||||||
@ -3586,19 +3600,22 @@ void Session::handleTorrentTrackersRemoved(TorrentHandle *const torrent, const Q
|
|||||||
|
|
||||||
void Session::handleTorrentTrackersChanged(TorrentHandle *const torrent)
|
void Session::handleTorrentTrackersChanged(TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit trackersChanged(torrent);
|
emit trackersChanged(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds)
|
void Session::handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds)
|
||||||
{
|
{
|
||||||
foreach (const QUrl &newUrlSeed, newUrlSeeds)
|
saveTorrentResumeData(torrent);
|
||||||
Logger::instance()->addMessage(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name()));
|
for (const QUrl &newUrlSeed : newUrlSeeds)
|
||||||
|
LogMsg(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList<QUrl> &urlSeeds)
|
void Session::handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList<QUrl> &urlSeeds)
|
||||||
{
|
{
|
||||||
foreach (const QUrl &urlSeed, urlSeeds)
|
saveTorrentResumeData(torrent);
|
||||||
Logger::instance()->addMessage(tr("URL seed '%1' was removed from torrent '%2'").arg(urlSeed.toString(), torrent->name()));
|
for (const QUrl &urlSeed : urlSeeds)
|
||||||
|
LogMsg(tr("URL seed '%1' was removed from torrent '%2'").arg(urlSeed.toString(), torrent->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::handleTorrentMetadataReceived(TorrentHandle *const torrent)
|
void Session::handleTorrentMetadataReceived(TorrentHandle *const torrent)
|
||||||
@ -3626,6 +3643,7 @@ void Session::handleTorrentPaused(TorrentHandle *const torrent)
|
|||||||
|
|
||||||
void Session::handleTorrentResumed(TorrentHandle *const torrent)
|
void Session::handleTorrentResumed(TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
|
saveTorrentResumeData(torrent);
|
||||||
emit torrentResumed(torrent);
|
emit torrentResumed(torrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4012,6 +4030,7 @@ void Session::handleAlert(libt::alert *a)
|
|||||||
case libt::storage_moved_alert::alert_type:
|
case libt::storage_moved_alert::alert_type:
|
||||||
case libt::storage_moved_failed_alert::alert_type:
|
case libt::storage_moved_failed_alert::alert_type:
|
||||||
case libt::torrent_paused_alert::alert_type:
|
case libt::torrent_paused_alert::alert_type:
|
||||||
|
case libt::torrent_resumed_alert::alert_type:
|
||||||
case libt::tracker_error_alert::alert_type:
|
case libt::tracker_error_alert::alert_type:
|
||||||
case libt::tracker_reply_alert::alert_type:
|
case libt::tracker_reply_alert::alert_type:
|
||||||
case libt::tracker_warning_alert::alert_type:
|
case libt::tracker_warning_alert::alert_type:
|
||||||
|
@ -480,6 +480,7 @@ namespace BitTorrent
|
|||||||
|
|
||||||
// TorrentHandle interface
|
// TorrentHandle interface
|
||||||
void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
|
void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
|
||||||
|
void handleTorrentNameChanged(TorrentHandle *const torrent);
|
||||||
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
|
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
|
||||||
void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory);
|
void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory);
|
||||||
void handleTorrentTagAdded(TorrentHandle *const torrent, const QString &tag);
|
void handleTorrentTagAdded(TorrentHandle *const torrent, const QString &tag);
|
||||||
|
@ -191,7 +191,6 @@ TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle
|
|||||||
, m_hasRootFolder(data.hasRootFolder)
|
, m_hasRootFolder(data.hasRootFolder)
|
||||||
, m_needsToSetFirstLastPiecePriority(false)
|
, m_needsToSetFirstLastPiecePriority(false)
|
||||||
, m_pauseAfterRecheck(false)
|
, m_pauseAfterRecheck(false)
|
||||||
, m_needSaveResumeData(false)
|
|
||||||
{
|
{
|
||||||
if (m_useAutoTMM)
|
if (m_useAutoTMM)
|
||||||
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
||||||
@ -488,8 +487,6 @@ bool TorrentHandle::connectPeer(const PeerAddress &peerAddress)
|
|||||||
|
|
||||||
bool TorrentHandle::needSaveResumeData() const
|
bool TorrentHandle::needSaveResumeData() const
|
||||||
{
|
{
|
||||||
if (m_needSaveResumeData) return true;
|
|
||||||
|
|
||||||
return m_nativeHandle.need_save_resume_data();
|
return m_nativeHandle.need_save_resume_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +496,6 @@ void TorrentHandle::saveResumeData(bool updateStatus)
|
|||||||
this->updateStatus();
|
this->updateStatus();
|
||||||
|
|
||||||
m_nativeHandle.save_resume_data();
|
m_nativeHandle.save_resume_data();
|
||||||
m_needSaveResumeData = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TorrentHandle::filesCount() const
|
int TorrentHandle::filesCount() const
|
||||||
@ -573,7 +569,6 @@ bool TorrentHandle::addTag(const QString &tag)
|
|||||||
return false;
|
return false;
|
||||||
m_tags.insert(tag);
|
m_tags.insert(tag);
|
||||||
m_session->handleTorrentTagAdded(this, tag);
|
m_session->handleTorrentTagAdded(this, tag);
|
||||||
m_needSaveResumeData = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -583,7 +578,6 @@ bool TorrentHandle::removeTag(const QString &tag)
|
|||||||
{
|
{
|
||||||
if (m_tags.remove(tag)) {
|
if (m_tags.remove(tag)) {
|
||||||
m_session->handleTorrentTagRemoved(this, tag);
|
m_session->handleTorrentTagRemoved(this, tag);
|
||||||
m_needSaveResumeData = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1198,7 +1192,7 @@ void TorrentHandle::setName(const QString &name)
|
|||||||
{
|
{
|
||||||
if (m_name != name) {
|
if (m_name != name) {
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_needSaveResumeData = true;
|
m_session->handleTorrentNameChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,7 +1208,6 @@ bool TorrentHandle::setCategory(const QString &category)
|
|||||||
|
|
||||||
QString oldCategory = m_category;
|
QString oldCategory = m_category;
|
||||||
m_category = category;
|
m_category = category;
|
||||||
m_needSaveResumeData = true;
|
|
||||||
m_session->handleTorrentCategoryChanged(this, oldCategory);
|
m_session->handleTorrentCategoryChanged(this, oldCategory);
|
||||||
|
|
||||||
if (m_useAutoTMM) {
|
if (m_useAutoTMM) {
|
||||||
@ -1252,7 +1245,6 @@ void TorrentHandle::move_impl(QString path, bool overwrite)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_savePath = path;
|
m_savePath = path;
|
||||||
m_needSaveResumeData = true;
|
|
||||||
m_session->handleTorrentSavePathChanged(this);
|
m_session->handleTorrentSavePathChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1806,6 +1798,9 @@ void TorrentHandle::handleAlert(libtorrent::alert *a)
|
|||||||
case libt::torrent_paused_alert::alert_type:
|
case libt::torrent_paused_alert::alert_type:
|
||||||
handleTorrentPausedAlert(static_cast<libt::torrent_paused_alert*>(a));
|
handleTorrentPausedAlert(static_cast<libt::torrent_paused_alert*>(a));
|
||||||
break;
|
break;
|
||||||
|
case libt::torrent_resumed_alert::alert_type:
|
||||||
|
handleTorrentResumedAlert(static_cast<libt::torrent_resumed_alert*>(a));
|
||||||
|
break;
|
||||||
case libt::tracker_error_alert::alert_type:
|
case libt::tracker_error_alert::alert_type:
|
||||||
handleTrackerErrorAlert(static_cast<libt::tracker_error_alert*>(a));
|
handleTrackerErrorAlert(static_cast<libt::tracker_error_alert*>(a));
|
||||||
break;
|
break;
|
||||||
@ -1928,7 +1923,6 @@ void TorrentHandle::setRatioLimit(qreal limit)
|
|||||||
|
|
||||||
if (m_ratioLimit != limit) {
|
if (m_ratioLimit != limit) {
|
||||||
m_ratioLimit = limit;
|
m_ratioLimit = limit;
|
||||||
m_needSaveResumeData = true;
|
|
||||||
m_session->handleTorrentShareLimitChanged(this);
|
m_session->handleTorrentShareLimitChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1942,7 +1936,6 @@ void TorrentHandle::setSeedingTimeLimit(int limit)
|
|||||||
|
|
||||||
if (m_seedingTimeLimit != limit) {
|
if (m_seedingTimeLimit != limit) {
|
||||||
m_seedingTimeLimit = limit;
|
m_seedingTimeLimit = limit;
|
||||||
m_needSaveResumeData = true;
|
|
||||||
m_session->handleTorrentShareLimitChanged(this);
|
m_session->handleTorrentShareLimitChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,6 @@ namespace BitTorrent
|
|||||||
bool m_needsToSetFirstLastPiecePriority;
|
bool m_needsToSetFirstLastPiecePriority;
|
||||||
|
|
||||||
bool m_pauseAfterRecheck;
|
bool m_pauseAfterRecheck;
|
||||||
bool m_needSaveResumeData;
|
|
||||||
QHash<QString, TrackerInfo> m_trackerInfos;
|
QHash<QString, TrackerInfo> m_trackerInfos;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user