Browse Source

Merge pull request #14354 from glassez/missing-files

Improve handling of "missing files" torrents
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
3dfd0ff3b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      src/base/bittorrent/torrentimpl.cpp

32
src/base/bittorrent/torrentimpl.cpp

@ -1387,6 +1387,7 @@ void TorrentImpl::resume(const TorrentOperatingMode mode)
{ {
m_hasMissingFiles = false; m_hasMissingFiles = false;
m_isStopped = false; m_isStopped = false;
m_ltAddTorrentParams.ti = std::const_pointer_cast<lt::torrent_info>(m_nativeHandle.torrent_file());
reload(); reload();
updateStatus(); updateStatus();
return; return;
@ -1446,8 +1447,21 @@ void TorrentImpl::handleMoveStorageJobFinished(const bool hasOutstandingJob)
saveResumeData(); saveResumeData();
while ((m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty()) if (!m_storageIsMoving)
m_moveFinishedTriggers.takeFirst()(); {
if (m_hasMissingFiles)
{
// it can be moved to the proper location
m_hasMissingFiles = false;
m_ltAddTorrentParams.save_path = m_nativeStatus.save_path;
m_ltAddTorrentParams.ti = std::const_pointer_cast<lt::torrent_info>(m_nativeHandle.torrent_file());
reload();
updateStatus();
}
while ((m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty())
m_moveFinishedTriggers.takeFirst()();
}
} }
void TorrentImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p) void TorrentImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p)
@ -1565,7 +1579,19 @@ void TorrentImpl::handleTorrentResumedAlert(const lt::torrent_resumed_alert *p)
void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p) void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
{ {
if (!m_hasMissingFiles) if (m_hasMissingFiles)
{
const auto havePieces = m_ltAddTorrentParams.have_pieces;
const auto unfinishedPieces = m_ltAddTorrentParams.unfinished_pieces;
const auto verifiedPieces = m_ltAddTorrentParams.verified_pieces;
// Update recent resume data but preserve existing progress
m_ltAddTorrentParams = p->params;
m_ltAddTorrentParams.have_pieces = havePieces;
m_ltAddTorrentParams.unfinished_pieces = unfinishedPieces;
m_ltAddTorrentParams.verified_pieces = verifiedPieces;
}
else
{ {
// Update recent resume data // Update recent resume data
m_ltAddTorrentParams = p->params; m_ltAddTorrentParams = p->params;

Loading…
Cancel
Save