|
|
@ -254,7 +254,7 @@ TorrentImpl::TorrentImpl(SessionImpl *session, lt::session *nativeSession |
|
|
|
, m_seedingTimeLimit(params.seedingTimeLimit) |
|
|
|
, m_seedingTimeLimit(params.seedingTimeLimit) |
|
|
|
, m_operatingMode(params.operatingMode) |
|
|
|
, m_operatingMode(params.operatingMode) |
|
|
|
, m_contentLayout(params.contentLayout) |
|
|
|
, m_contentLayout(params.contentLayout) |
|
|
|
, m_hasSeedStatus(params.hasSeedStatus) |
|
|
|
, m_hasFinishedStatus(params.hasFinishedStatus) |
|
|
|
, m_hasFirstLastPiecePriority(params.firstLastPiecePriority) |
|
|
|
, m_hasFirstLastPiecePriority(params.firstLastPiecePriority) |
|
|
|
, m_useAutoTMM(params.useAutoTMM) |
|
|
|
, m_useAutoTMM(params.useAutoTMM) |
|
|
|
, m_isStopped(params.stopped) |
|
|
|
, m_isStopped(params.stopped) |
|
|
@ -431,8 +431,7 @@ void TorrentImpl::setSavePath(const Path &path) |
|
|
|
|
|
|
|
|
|
|
|
m_session->handleTorrentNeedSaveResumeData(this); |
|
|
|
m_session->handleTorrentNeedSaveResumeData(this); |
|
|
|
|
|
|
|
|
|
|
|
const bool isFinished = isSeed() || m_hasSeedStatus; |
|
|
|
if (isFinished() || m_hasFinishedStatus || downloadPath().isEmpty()) |
|
|
|
if (isFinished || downloadPath().isEmpty()) |
|
|
|
|
|
|
|
moveStorage(savePath(), MoveStorageMode::KeepExistingFiles); |
|
|
|
moveStorage(savePath(), MoveStorageMode::KeepExistingFiles); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -455,8 +454,8 @@ void TorrentImpl::setDownloadPath(const Path &path) |
|
|
|
|
|
|
|
|
|
|
|
m_session->handleTorrentNeedSaveResumeData(this); |
|
|
|
m_session->handleTorrentNeedSaveResumeData(this); |
|
|
|
|
|
|
|
|
|
|
|
const bool isFinished = isSeed() || m_hasSeedStatus; |
|
|
|
const bool isIncomplete = !(isFinished() || m_hasFinishedStatus); |
|
|
|
if (!isFinished) |
|
|
|
if (isIncomplete) |
|
|
|
moveStorage((m_downloadPath.isEmpty() ? savePath() : m_downloadPath), MoveStorageMode::KeepExistingFiles); |
|
|
|
moveStorage((m_downloadPath.isEmpty() ? savePath() : m_downloadPath), MoveStorageMode::KeepExistingFiles); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -999,7 +998,7 @@ bool TorrentImpl::isErrored() const |
|
|
|
|| (m_state == TorrentState::Error)); |
|
|
|
|| (m_state == TorrentState::Error)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentImpl::isSeed() const |
|
|
|
bool TorrentImpl::isFinished() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return ((m_nativeStatus.state == lt::torrent_status::finished) |
|
|
|
return ((m_nativeStatus.state == lt::torrent_status::finished) |
|
|
|
|| (m_nativeStatus.state == lt::torrent_status::seeding)); |
|
|
|
|| (m_nativeStatus.state == lt::torrent_status::seeding)); |
|
|
@ -1055,9 +1054,9 @@ void TorrentImpl::updateState() |
|
|
|
else if ((m_nativeStatus.state == lt::torrent_status::checking_files) && !isPaused()) |
|
|
|
else if ((m_nativeStatus.state == lt::torrent_status::checking_files) && !isPaused()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// If the torrent is not just in the "checking" state, but is being actually checked
|
|
|
|
// If the torrent is not just in the "checking" state, but is being actually checked
|
|
|
|
m_state = m_hasSeedStatus ? TorrentState::CheckingUploading : TorrentState::CheckingDownloading; |
|
|
|
m_state = m_hasFinishedStatus ? TorrentState::CheckingUploading : TorrentState::CheckingDownloading; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (isSeed()) |
|
|
|
else if (isFinished()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isPaused()) |
|
|
|
if (isPaused()) |
|
|
|
m_state = TorrentState::PausedUploading; |
|
|
|
m_state = TorrentState::PausedUploading; |
|
|
@ -1145,7 +1144,7 @@ qlonglong TorrentImpl::eta() const |
|
|
|
|
|
|
|
|
|
|
|
const SpeedSampleAvg speedAverage = m_payloadRateMonitor.average(); |
|
|
|
const SpeedSampleAvg speedAverage = m_payloadRateMonitor.average(); |
|
|
|
|
|
|
|
|
|
|
|
if (isSeed()) |
|
|
|
if (isFinished()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const qreal maxRatioValue = maxRatio(); |
|
|
|
const qreal maxRatioValue = maxRatio(); |
|
|
|
const int maxSeedingTimeValue = maxSeedingTime(); |
|
|
|
const int maxSeedingTimeValue = maxSeedingTime(); |
|
|
@ -1816,9 +1815,9 @@ void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p) |
|
|
|
if (!m_hasMissingFiles) |
|
|
|
if (!m_hasMissingFiles) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ((progress() < 1.0) && (wantedSize() > 0)) |
|
|
|
if ((progress() < 1.0) && (wantedSize() > 0)) |
|
|
|
m_hasSeedStatus = false; |
|
|
|
m_hasFinishedStatus = false; |
|
|
|
else if (progress() == 1.0) |
|
|
|
else if (progress() == 1.0) |
|
|
|
m_hasSeedStatus = true; |
|
|
|
m_hasFinishedStatus = true; |
|
|
|
|
|
|
|
|
|
|
|
adjustStorageLocation(); |
|
|
|
adjustStorageLocation(); |
|
|
|
manageIncompleteFiles(); |
|
|
|
manageIncompleteFiles(); |
|
|
@ -1845,12 +1844,12 @@ void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p |
|
|
|
Q_UNUSED(p); |
|
|
|
Q_UNUSED(p); |
|
|
|
|
|
|
|
|
|
|
|
m_hasMissingFiles = false; |
|
|
|
m_hasMissingFiles = false; |
|
|
|
if (m_hasSeedStatus) |
|
|
|
if (m_hasFinishedStatus) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
m_statusUpdatedTriggers.enqueue([this]() |
|
|
|
m_statusUpdatedTriggers.enqueue([this]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_hasSeedStatus = true; |
|
|
|
m_hasFinishedStatus = true; |
|
|
|
|
|
|
|
|
|
|
|
adjustStorageLocation(); |
|
|
|
adjustStorageLocation(); |
|
|
|
manageIncompleteFiles(); |
|
|
|
manageIncompleteFiles(); |
|
|
@ -1977,7 +1976,7 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params ¶ms) |
|
|
|
resumeData.ratioLimit = m_ratioLimit; |
|
|
|
resumeData.ratioLimit = m_ratioLimit; |
|
|
|
resumeData.seedingTimeLimit = m_seedingTimeLimit; |
|
|
|
resumeData.seedingTimeLimit = m_seedingTimeLimit; |
|
|
|
resumeData.firstLastPiecePriority = m_hasFirstLastPiecePriority; |
|
|
|
resumeData.firstLastPiecePriority = m_hasFirstLastPiecePriority; |
|
|
|
resumeData.hasSeedStatus = m_hasSeedStatus; |
|
|
|
resumeData.hasFinishedStatus = m_hasFinishedStatus; |
|
|
|
resumeData.stopped = m_isStopped; |
|
|
|
resumeData.stopped = m_isStopped; |
|
|
|
resumeData.stopCondition = m_stopCondition; |
|
|
|
resumeData.stopCondition = m_stopCondition; |
|
|
|
resumeData.operatingMode = m_operatingMode; |
|
|
|
resumeData.operatingMode = m_operatingMode; |
|
|
@ -2203,8 +2202,7 @@ void TorrentImpl::manageIncompleteFiles() |
|
|
|
void TorrentImpl::adjustStorageLocation() |
|
|
|
void TorrentImpl::adjustStorageLocation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const Path downloadPath = this->downloadPath(); |
|
|
|
const Path downloadPath = this->downloadPath(); |
|
|
|
const bool isFinished = isSeed() || m_hasSeedStatus; |
|
|
|
const Path targetPath = ((isFinished() || m_hasFinishedStatus || downloadPath.isEmpty()) ? savePath() : downloadPath); |
|
|
|
const Path targetPath = ((isFinished || downloadPath.isEmpty()) ? savePath() : downloadPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((targetPath != actualStorageLocation()) || isMoveInProgress()) |
|
|
|
if ((targetPath != actualStorageLocation()) || isMoveInProgress()) |
|
|
|
moveStorage(targetPath, MoveStorageMode::Overwrite); |
|
|
|
moveStorage(targetPath, MoveStorageMode::Overwrite); |
|
|
@ -2677,7 +2675,7 @@ void TorrentImpl::prioritizeFiles(const QVector<DownloadPriority> &priorities) |
|
|
|
&& (priorities[i] > DownloadPriority::Ignored) |
|
|
|
&& (priorities[i] > DownloadPriority::Ignored) |
|
|
|
&& !m_completedFiles.at(i)) |
|
|
|
&& !m_completedFiles.at(i)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_hasSeedStatus = false; |
|
|
|
m_hasFinishedStatus = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|