mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-03 02:14:16 +00:00
Merge pull request #14123 from glassez/restart-missing-files
Don't re-check "missing files" torrents when re-start
This commit is contained in:
commit
4bb3d13921
@ -1308,44 +1308,57 @@ void TorrentHandleImpl::fileSearchFinished(const QString &savePath, const QStrin
|
|||||||
|
|
||||||
void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames)
|
void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames)
|
||||||
{
|
{
|
||||||
const auto queuePos = m_nativeHandle.queue_position();
|
lt::add_torrent_params &p = m_ltAddTorrentParams;
|
||||||
|
|
||||||
lt::add_torrent_params p = m_ltAddTorrentParams;
|
|
||||||
p.ti = std::const_pointer_cast<lt::torrent_info>(m_nativeHandle.torrent_file());
|
p.ti = std::const_pointer_cast<lt::torrent_info>(m_nativeHandle.torrent_file());
|
||||||
|
|
||||||
m_nativeSession->remove_torrent(m_nativeHandle, lt::session::delete_partfile);
|
|
||||||
|
|
||||||
for (int i = 0; i < fileNames.size(); ++i)
|
for (int i = 0; i < fileNames.size(); ++i)
|
||||||
p.renamed_files[lt::file_index_t {i}] = fileNames[i].toStdString();
|
p.renamed_files[lt::file_index_t {i}] = fileNames[i].toStdString();
|
||||||
|
|
||||||
p.save_path = Utils::Fs::toNativePath(savePath).toStdString();
|
p.save_path = Utils::Fs::toNativePath(savePath).toStdString();
|
||||||
p.flags |= lt::torrent_flags::update_subscribe
|
|
||||||
| lt::torrent_flags::override_trackers
|
|
||||||
| lt::torrent_flags::override_web_seeds;
|
|
||||||
|
|
||||||
m_nativeHandle = m_nativeSession->add_torrent(p);
|
reload();
|
||||||
m_nativeHandle.queue_position_set(queuePos);
|
|
||||||
|
|
||||||
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
|
||||||
// If first/last piece priority was specified when adding this torrent,
|
// If first/last piece priority was specified when adding this torrent,
|
||||||
// we should apply it now that we have metadata:
|
// we should apply it now that we have metadata:
|
||||||
if (m_hasFirstLastPiecePriority)
|
if (m_hasFirstLastPiecePriority)
|
||||||
applyFirstLastPiecePriority(true);
|
applyFirstLastPiecePriority(true);
|
||||||
|
|
||||||
if (!m_isStopped)
|
|
||||||
{
|
|
||||||
setAutoManaged(m_operatingMode == TorrentOperatingMode::AutoManaged);
|
|
||||||
if (m_operatingMode == TorrentOperatingMode::Forced)
|
|
||||||
m_nativeHandle.resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_maintenanceJob = MaintenanceJob::None;
|
m_maintenanceJob = MaintenanceJob::None;
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
|
||||||
m_session->handleTorrentMetadataReceived(this);
|
m_session->handleTorrentMetadataReceived(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TorrentHandleImpl::reload()
|
||||||
|
{
|
||||||
|
const auto queuePos = m_nativeHandle.queue_position();
|
||||||
|
|
||||||
|
m_nativeSession->remove_torrent(m_nativeHandle, lt::session::delete_partfile);
|
||||||
|
|
||||||
|
lt::add_torrent_params p = m_ltAddTorrentParams;
|
||||||
|
p.flags |= lt::torrent_flags::update_subscribe
|
||||||
|
| lt::torrent_flags::override_trackers
|
||||||
|
| lt::torrent_flags::override_web_seeds;
|
||||||
|
|
||||||
|
if (m_isStopped)
|
||||||
|
{
|
||||||
|
p.flags |= lt::torrent_flags::paused;
|
||||||
|
p.flags &= ~lt::torrent_flags::auto_managed;
|
||||||
|
}
|
||||||
|
else if (m_operatingMode == TorrentOperatingMode::AutoManaged)
|
||||||
|
{
|
||||||
|
p.flags |= (lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p.flags &= ~(lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_nativeHandle = m_nativeSession->add_torrent(p);
|
||||||
|
m_nativeHandle.queue_position_set(queuePos);
|
||||||
|
|
||||||
|
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
||||||
|
}
|
||||||
|
|
||||||
void TorrentHandleImpl::pause()
|
void TorrentHandleImpl::pause()
|
||||||
{
|
{
|
||||||
if (!m_isStopped)
|
if (!m_isStopped)
|
||||||
@ -1368,14 +1381,17 @@ void TorrentHandleImpl::resume(const TorrentOperatingMode mode)
|
|||||||
if (hasError())
|
if (hasError())
|
||||||
m_nativeHandle.clear_error();
|
m_nativeHandle.clear_error();
|
||||||
|
|
||||||
|
m_operatingMode = mode;
|
||||||
|
|
||||||
if (m_hasMissingFiles)
|
if (m_hasMissingFiles)
|
||||||
{
|
{
|
||||||
m_hasMissingFiles = false;
|
m_hasMissingFiles = false;
|
||||||
m_nativeHandle.force_recheck();
|
m_isStopped = false;
|
||||||
|
reload();
|
||||||
|
updateStatus();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_operatingMode = mode;
|
|
||||||
|
|
||||||
if (m_isStopped)
|
if (m_isStopped)
|
||||||
{
|
{
|
||||||
// Torrent may have been temporarily resumed to perform checking files
|
// Torrent may have been temporarily resumed to perform checking files
|
||||||
|
@ -291,6 +291,7 @@ namespace BitTorrent
|
|||||||
void applyFirstLastPiecePriority(bool enabled, const QVector<DownloadPriority> &updatedFilePrio = {});
|
void applyFirstLastPiecePriority(bool enabled, const QVector<DownloadPriority> &updatedFilePrio = {});
|
||||||
|
|
||||||
void endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames);
|
void endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames);
|
||||||
|
void reload();
|
||||||
|
|
||||||
Session *const m_session;
|
Session *const m_session;
|
||||||
lt::session *m_nativeSession;
|
lt::session *m_nativeSession;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user