@@ -1308,44 +1308,57 @@ void TorrentHandleImpl::fileSearchFinished(const QString &savePath, const QStrin
13081308
13091309void TorrentHandleImpl::endReceivedMetadataHandling (const QString &savePath, const QStringList &fileNames)
13101310{
1311- const auto queuePos = m_nativeHandle. queue_position () ;
1311+ lt::add_torrent_params &p = m_ltAddTorrentParams ;
13121312
1313- lt::add_torrent_params p = m_ltAddTorrentParams;
13141313 p.ti = std::const_pointer_cast<lt::torrent_info>(m_nativeHandle.torrent_file ());
1315-
1316- m_nativeSession->remove_torrent (m_nativeHandle, lt::session::delete_partfile);
1317-
13181314 for (int i = 0 ; i < fileNames.size (); ++i)
13191315 p.renamed_files [lt::file_index_t {i}] = fileNames[i].toStdString ();
1320-
13211316 p.save_path = Utils::Fs::toNativePath (savePath).toStdString ();
1322- p.flags |= lt::torrent_flags::update_subscribe
1323- | lt::torrent_flags::override_trackers
1324- | lt::torrent_flags::override_web_seeds;
13251317
1326- m_nativeHandle = m_nativeSession->add_torrent (p);
1327- m_nativeHandle.queue_position_set (queuePos);
1318+ reload ();
13281319
1329- m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file ()};
13301320 // If first/last piece priority was specified when adding this torrent,
13311321 // we should apply it now that we have metadata:
13321322 if (m_hasFirstLastPiecePriority)
13331323 applyFirstLastPiecePriority (true );
13341324
1335- if (!m_isStopped)
1336- {
1337- setAutoManaged (m_operatingMode == TorrentOperatingMode::AutoManaged);
1338- if (m_operatingMode == TorrentOperatingMode::Forced)
1339- m_nativeHandle.resume ();
1340- }
1341-
13421325 m_maintenanceJob = MaintenanceJob::None;
1343-
13441326 updateStatus ();
13451327
13461328 m_session->handleTorrentMetadataReceived (this );
13471329}
13481330
1331+ void TorrentHandleImpl::reload ()
1332+ {
1333+ const auto queuePos = m_nativeHandle.queue_position ();
1334+
1335+ m_nativeSession->remove_torrent (m_nativeHandle, lt::session::delete_partfile);
1336+
1337+ lt::add_torrent_params p = m_ltAddTorrentParams;
1338+ p.flags |= lt::torrent_flags::update_subscribe
1339+ | lt::torrent_flags::override_trackers
1340+ | lt::torrent_flags::override_web_seeds;
1341+
1342+ if (m_isStopped)
1343+ {
1344+ p.flags |= lt::torrent_flags::paused;
1345+ p.flags &= ~lt::torrent_flags::auto_managed;
1346+ }
1347+ else if (m_operatingMode == TorrentOperatingMode::AutoManaged)
1348+ {
1349+ p.flags |= (lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
1350+ }
1351+ else
1352+ {
1353+ p.flags &= ~(lt::torrent_flags::auto_managed | lt::torrent_flags::paused);
1354+ }
1355+
1356+ m_nativeHandle = m_nativeSession->add_torrent (p);
1357+ m_nativeHandle.queue_position_set (queuePos);
1358+
1359+ m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file ()};
1360+ }
1361+
13491362void TorrentHandleImpl::pause ()
13501363{
13511364 if (!m_isStopped)
0 commit comments