mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 07:46:17 -07:00
Don't stuck loading on mismatching info-hashes in resume data
PR #20262. Closes #20251.
This commit is contained in:
parent
97c0abcbf0
commit
14513d051d
3 changed files with 34 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -1274,13 +1274,13 @@ void SessionImpl::prepareStartup()
|
|||
context->isLoadFinished = true;
|
||||
});
|
||||
|
||||
connect(this, &SessionImpl::torrentsLoaded, context, [this, context](const QVector<Torrent *> &torrents)
|
||||
connect(this, &SessionImpl::addTorrentAlertsReceived, context, [this, context](const qsizetype alertsCount)
|
||||
{
|
||||
context->processingResumeDataCount -= torrents.count();
|
||||
context->finishedResumeDataCount += torrents.count();
|
||||
context->processingResumeDataCount -= alertsCount;
|
||||
context->finishedResumeDataCount += alertsCount;
|
||||
if (!context->isLoadedResumeDataHandlingEnqueued)
|
||||
{
|
||||
QMetaObject::invokeMethod(this, [this, context]() { handleLoadedResumeData(context); }, Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, [this, context] { handleLoadedResumeData(context); }, Qt::QueuedConnection);
|
||||
context->isLoadedResumeDataHandlingEnqueued = true;
|
||||
}
|
||||
|
||||
|
@ -5331,11 +5331,14 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector<lt::alert *> &alerts)
|
|||
if (!isRestored())
|
||||
loadedTorrents.reserve(MAX_PROCESSING_RESUMEDATA_COUNT);
|
||||
|
||||
qsizetype alertsCount = 0;
|
||||
for (const lt::alert *a : alerts)
|
||||
{
|
||||
if (a->type() != lt::add_torrent_alert::alert_type)
|
||||
continue;
|
||||
|
||||
++alertsCount;
|
||||
|
||||
const auto *alert = static_cast<const lt::add_torrent_alert *>(a);
|
||||
if (alert->error)
|
||||
{
|
||||
|
@ -5345,6 +5348,7 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector<lt::alert *> &alerts)
|
|||
|
||||
const lt::add_torrent_params ¶ms = alert->params;
|
||||
const bool hasMetadata = (params.ti && params.ti->is_valid());
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
const InfoHash infoHash {(hasMetadata ? params.ti->info_hashes() : params.info_hashes)};
|
||||
if (infoHash.isHybrid())
|
||||
|
@ -5370,10 +5374,9 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector<lt::alert *> &alerts)
|
|||
}
|
||||
}
|
||||
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
const InfoHash infoHash {alert->handle.info_hashes()};
|
||||
#else
|
||||
|
@ -5391,7 +5394,7 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector<lt::alert *> &alerts)
|
|||
loadedTorrents.append(torrent);
|
||||
}
|
||||
else if (const auto downloadedMetadataIter = m_downloadedMetadata.find(torrentID)
|
||||
; downloadedMetadataIter != m_downloadedMetadata.end())
|
||||
; downloadedMetadataIter != m_downloadedMetadata.end())
|
||||
{
|
||||
downloadedMetadataIter.value() = alert->handle;
|
||||
if (infoHash.isHybrid())
|
||||
|
@ -5403,11 +5406,16 @@ void SessionImpl::handleAddTorrentAlerts(const std::vector<lt::alert *> &alerts)
|
|||
}
|
||||
}
|
||||
|
||||
if (!loadedTorrents.isEmpty())
|
||||
if (alertsCount > 0)
|
||||
{
|
||||
if (isRestored())
|
||||
m_torrentsQueueChanged = true;
|
||||
emit torrentsLoaded(loadedTorrents);
|
||||
emit addTorrentAlertsReceived(alertsCount);
|
||||
|
||||
if (!loadedTorrents.isEmpty())
|
||||
{
|
||||
if (isRestored())
|
||||
m_torrentsQueueChanged = true;
|
||||
emit torrentsLoaded(loadedTorrents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue