1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Ignore some actions on uninitialized torrents

Some actions can lead to an inconsistent state if applied
to an uninitialized torrent, so we just ignore them.
This commit is contained in:
Vladimir Golovnev (Glassez) 2019-07-14 11:29:49 +03:00
parent 0aa6f39db0
commit 9462685c78
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7

View File

@ -223,7 +223,7 @@ TorrentHandle::TorrentHandle(Session *session, const lt::torrent_handle &nativeH
// Resume torrent because it was added in "resumed" state
// but it's actually paused during initialization.
m_startupState = Starting;
resume(m_needsToStartForced);
resume_impl(m_needsToStartForced);
}
else {
m_startupState = Started;
@ -1298,6 +1298,8 @@ bool TorrentHandle::setCategory(const QString &category)
void TorrentHandle::move(QString path)
{
if (m_startupState != Started) return;
m_useAutoTMM = false;
m_session->handleTorrentSavingModeChanged(this);
@ -1336,6 +1338,7 @@ void TorrentHandle::forceDHTAnnounce()
void TorrentHandle::forceRecheck()
{
if (m_startupState != Started) return;
if (!hasMetadata()) return;
m_nativeHandle.force_recheck();
@ -1433,6 +1436,7 @@ void TorrentHandle::toggleFirstLastPiecePriority()
void TorrentHandle::pause()
{
if (m_startupState != Started) return;
if (isPaused()) return;
setAutoManaged(false);
@ -1447,6 +1451,8 @@ void TorrentHandle::pause()
void TorrentHandle::resume(bool forced)
{
if (m_startupState != Started) return;
resume_impl(forced);
}
@ -1492,6 +1498,8 @@ void TorrentHandle::moveStorage(const QString &newPath, bool overwrite)
void TorrentHandle::renameFile(const int index, const QString &name)
{
if (m_startupState != Started) return;
m_oldPath[LTFileIndex {index}].push_back(filePath(index));
++m_renameCount;
m_nativeHandle.rename_file(index, Utils::Fs::toNativePath(name).toStdString());
@ -1626,7 +1634,7 @@ void TorrentHandle::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p
// Resume torrent because it was added in "resumed" state
// but it's actually paused during initialization.
m_startupState = Starting;
resume(m_needsToStartForced);
resume_impl(m_needsToStartForced);
}
else {
// Torrent that has missing files is paused.