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;
|
||||
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(torrent);
|
||||
saveTorrentResumeData(torrent);
|
||||
updateSeedingLimitTimer();
|
||||
}
|
||||
|
||||
void Session::saveTorrentResumeData(TorrentHandle *const torrent, bool finalSave)
|
||||
{
|
||||
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));
|
||||
torrent->saveResumeData(finalSave);
|
||||
++m_numResumeData;
|
||||
}
|
||||
|
||||
void Session::handleTorrentNameChanged(TorrentHandle *const torrent)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
}
|
||||
|
||||
void Session::handleTorrentSavePathChanged(TorrentHandle *const torrent)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit torrentSavePathChanged(torrent);
|
||||
}
|
||||
|
||||
void Session::handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit torrentCategoryChanged(torrent, oldCategory);
|
||||
}
|
||||
|
||||
void Session::handleTorrentTagAdded(TorrentHandle *const torrent, const QString &tag)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit torrentTagAdded(torrent, tag);
|
||||
}
|
||||
|
||||
void Session::handleTorrentTagRemoved(TorrentHandle *const torrent, const QString &tag)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit torrentTagRemoved(torrent, tag);
|
||||
}
|
||||
|
||||
void Session::handleTorrentSavingModeChanged(TorrentHandle *const torrent)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit torrentSavingModeChanged(torrent);
|
||||
}
|
||||
|
||||
void Session::handleTorrentTrackersAdded(TorrentHandle *const torrent, const QList<TrackerEntry> &newTrackers)
|
||||
{
|
||||
foreach (const TrackerEntry &newTracker, newTrackers)
|
||||
Logger::instance()->addMessage(tr("Tracker '%1' was added to torrent '%2'").arg(newTracker.url(), torrent->name()));
|
||||
saveTorrentResumeData(torrent);
|
||||
|
||||
for (const TrackerEntry &newTracker : newTrackers)
|
||||
LogMsg(tr("Tracker '%1' was added to torrent '%2'").arg(newTracker.url(), torrent->name()));
|
||||
emit trackersAdded(torrent, newTrackers);
|
||||
if (torrent->trackers().size() == newTrackers.size())
|
||||
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)
|
||||
{
|
||||
foreach (const TrackerEntry &deletedTracker, deletedTrackers)
|
||||
Logger::instance()->addMessage(tr("Tracker '%1' was deleted from torrent '%2'").arg(deletedTracker.url(), torrent->name()));
|
||||
saveTorrentResumeData(torrent);
|
||||
|
||||
for (const TrackerEntry &deletedTracker : deletedTrackers)
|
||||
LogMsg(tr("Tracker '%1' was deleted from torrent '%2'").arg(deletedTracker.url(), torrent->name()));
|
||||
emit trackersRemoved(torrent, deletedTrackers);
|
||||
if (torrent->trackers().size() == 0)
|
||||
emit trackerlessStateChanged(torrent, true);
|
||||
@ -3586,19 +3600,22 @@ void Session::handleTorrentTrackersRemoved(TorrentHandle *const torrent, const Q
|
||||
|
||||
void Session::handleTorrentTrackersChanged(TorrentHandle *const torrent)
|
||||
{
|
||||
saveTorrentResumeData(torrent);
|
||||
emit trackersChanged(torrent);
|
||||
}
|
||||
|
||||
void Session::handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds)
|
||||
{
|
||||
foreach (const QUrl &newUrlSeed, newUrlSeeds)
|
||||
Logger::instance()->addMessage(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name()));
|
||||
saveTorrentResumeData(torrent);
|
||||
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)
|
||||
{
|
||||
foreach (const QUrl &urlSeed, urlSeeds)
|
||||
Logger::instance()->addMessage(tr("URL seed '%1' was removed from torrent '%2'").arg(urlSeed.toString(), torrent->name()));
|
||||
saveTorrentResumeData(torrent);
|
||||
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)
|
||||
@ -3626,6 +3643,7 @@ void Session::handleTorrentPaused(TorrentHandle *const torrent)
|
||||
|
||||
void Session::handleTorrentResumed(TorrentHandle *const torrent)
|
||||
{
|
||||
saveTorrentResumeData(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_failed_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_reply_alert::alert_type:
|
||||
case libt::tracker_warning_alert::alert_type:
|
||||
|
@ -480,6 +480,7 @@ namespace BitTorrent
|
||||
|
||||
// TorrentHandle interface
|
||||
void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentNameChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory);
|
||||
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_needsToSetFirstLastPiecePriority(false)
|
||||
, m_pauseAfterRecheck(false)
|
||||
, m_needSaveResumeData(false)
|
||||
{
|
||||
if (m_useAutoTMM)
|
||||
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
||||
@ -488,8 +487,6 @@ bool TorrentHandle::connectPeer(const PeerAddress &peerAddress)
|
||||
|
||||
bool TorrentHandle::needSaveResumeData() const
|
||||
{
|
||||
if (m_needSaveResumeData) return true;
|
||||
|
||||
return m_nativeHandle.need_save_resume_data();
|
||||
}
|
||||
|
||||
@ -499,7 +496,6 @@ void TorrentHandle::saveResumeData(bool updateStatus)
|
||||
this->updateStatus();
|
||||
|
||||
m_nativeHandle.save_resume_data();
|
||||
m_needSaveResumeData = false;
|
||||
}
|
||||
|
||||
int TorrentHandle::filesCount() const
|
||||
@ -573,7 +569,6 @@ bool TorrentHandle::addTag(const QString &tag)
|
||||
return false;
|
||||
m_tags.insert(tag);
|
||||
m_session->handleTorrentTagAdded(this, tag);
|
||||
m_needSaveResumeData = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -583,7 +578,6 @@ bool TorrentHandle::removeTag(const QString &tag)
|
||||
{
|
||||
if (m_tags.remove(tag)) {
|
||||
m_session->handleTorrentTagRemoved(this, tag);
|
||||
m_needSaveResumeData = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1198,7 +1192,7 @@ void TorrentHandle::setName(const QString &name)
|
||||
{
|
||||
if (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;
|
||||
m_category = category;
|
||||
m_needSaveResumeData = true;
|
||||
m_session->handleTorrentCategoryChanged(this, oldCategory);
|
||||
|
||||
if (m_useAutoTMM) {
|
||||
@ -1252,7 +1245,6 @@ void TorrentHandle::move_impl(QString path, bool overwrite)
|
||||
}
|
||||
else {
|
||||
m_savePath = path;
|
||||
m_needSaveResumeData = true;
|
||||
m_session->handleTorrentSavePathChanged(this);
|
||||
}
|
||||
}
|
||||
@ -1806,6 +1798,9 @@ void TorrentHandle::handleAlert(libtorrent::alert *a)
|
||||
case libt::torrent_paused_alert::alert_type:
|
||||
handleTorrentPausedAlert(static_cast<libt::torrent_paused_alert*>(a));
|
||||
break;
|
||||
case libt::torrent_resumed_alert::alert_type:
|
||||
handleTorrentResumedAlert(static_cast<libt::torrent_resumed_alert*>(a));
|
||||
break;
|
||||
case libt::tracker_error_alert::alert_type:
|
||||
handleTrackerErrorAlert(static_cast<libt::tracker_error_alert*>(a));
|
||||
break;
|
||||
@ -1928,7 +1923,6 @@ void TorrentHandle::setRatioLimit(qreal limit)
|
||||
|
||||
if (m_ratioLimit != limit) {
|
||||
m_ratioLimit = limit;
|
||||
m_needSaveResumeData = true;
|
||||
m_session->handleTorrentShareLimitChanged(this);
|
||||
}
|
||||
}
|
||||
@ -1942,7 +1936,6 @@ void TorrentHandle::setSeedingTimeLimit(int limit)
|
||||
|
||||
if (m_seedingTimeLimit != limit) {
|
||||
m_seedingTimeLimit = limit;
|
||||
m_needSaveResumeData = true;
|
||||
m_session->handleTorrentShareLimitChanged(this);
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +461,6 @@ namespace BitTorrent
|
||||
bool m_needsToSetFirstLastPiecePriority;
|
||||
|
||||
bool m_pauseAfterRecheck;
|
||||
bool m_needSaveResumeData;
|
||||
QHash<QString, TrackerInfo> m_trackerInfos;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user