Browse Source

Merge pull request #14025 from glassez/fix-move

Fix bug of "move storage job" can be performed multiple times
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
4029f86c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      src/base/bittorrent/session.cpp

23
src/base/bittorrent/session.cpp

@ -4065,6 +4065,8 @@ void Session::moveTorrentStorage(const MoveStorageJob &job) const
void Session::handleMoveTorrentStorageJobFinished() void Session::handleMoveTorrentStorageJobFinished()
{ {
const MoveStorageJob finishedJob = m_moveStorageQueue.takeFirst(); const MoveStorageJob finishedJob = m_moveStorageQueue.takeFirst();
if (!m_moveStorageQueue.isEmpty())
moveTorrentStorage(m_moveStorageQueue.first());
const auto iter = std::find_if(m_moveStorageQueue.cbegin(), m_moveStorageQueue.cend() const auto iter = std::find_if(m_moveStorageQueue.cbegin(), m_moveStorageQueue.cend()
, [&finishedJob](const MoveStorageJob &job) , [&finishedJob](const MoveStorageJob &job)
@ -4076,22 +4078,17 @@ void Session::handleMoveTorrentStorageJobFinished()
TorrentHandleImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash()); TorrentHandleImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash());
if (torrent) if (torrent)
{
torrent->handleMoveStorageJobFinished(torrentHasOutstandingJob); torrent->handleMoveStorageJobFinished(torrentHasOutstandingJob);
}
if (!torrentHasOutstandingJob) else if (!torrentHasOutstandingJob)
{ {
if (!torrent) // Last job is completed for torrent that being removing, so actually remove it
{ const lt::torrent_handle nativeHandle {finishedJob.torrentHandle};
// Last job is completed for torrent that being removing, so actually remove it const RemovingTorrentData &removingTorrentData = m_removingTorrents[nativeHandle.info_hash()];
const lt::torrent_handle nativeHandle {finishedJob.torrentHandle}; if (removingTorrentData.deleteOption == Torrent)
const RemovingTorrentData &removingTorrentData = m_removingTorrents[nativeHandle.info_hash()]; m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_partfile);
if (removingTorrentData.deleteOption == Torrent)
m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_partfile);
}
} }
if (!m_moveStorageQueue.isEmpty())
moveTorrentStorage(m_moveStorageQueue.first());
} }
void Session::handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl) void Session::handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl)

Loading…
Cancel
Save