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

Correctly handle received metadata

It did not work correctly, since it assumed that 'lt::torrent_plugin' is created at an earlier stage and is able to track all changes in the torrent state, but in reality it turned out that it was created after the torrent moved to the `downloading_metadata` state, so we had to additionally handle it in the constructor.

PR #16121.
This commit is contained in:
Vladimir Golovnev 2022-01-16 16:06:15 +03:00 committed by GitHub
parent e93de54eb5
commit 4d54fb675f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,7 @@ namespace
NativeTorrentExtension::NativeTorrentExtension(const lt::torrent_handle &torrentHandle) NativeTorrentExtension::NativeTorrentExtension(const lt::torrent_handle &torrentHandle)
: m_torrentHandle {torrentHandle} : m_torrentHandle {torrentHandle}
{ {
on_state(m_torrentHandle.status({}).state);
} }
bool NativeTorrentExtension::on_pause() bool NativeTorrentExtension::on_pause()
@ -56,7 +57,10 @@ bool NativeTorrentExtension::on_pause()
void NativeTorrentExtension::on_state(const lt::torrent_status::state_t state) void NativeTorrentExtension::on_state(const lt::torrent_status::state_t state)
{ {
if (m_state == lt::torrent_status::downloading_metadata) if (m_state == lt::torrent_status::downloading_metadata)
m_torrentHandle.set_flags(lt::torrent_flags::stop_when_ready); {
m_torrentHandle.unset_flags(lt::torrent_flags::auto_managed);
m_torrentHandle.pause();
}
m_state = state; m_state = state;
} }