diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index a7f950453..3118b2760 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -5407,10 +5407,13 @@ void SessionImpl::handleTorrentDeletedAlert(const lt::torrent_deleted_alert *p) #endif const auto removingTorrentDataIter = m_removingTorrents.find(id); - if (removingTorrentDataIter == m_removingTorrents.end()) return; + // torrent_deleted_alert can also be posted due to deletion of partfile. Ignore it in such a case. + if (removingTorrentDataIter->deleteOption == DeleteTorrent) + return; + Utils::Fs::smartRemoveEmptyFolderTree(removingTorrentDataIter->pathToRemove); LogMsg(tr("Removed torrent and deleted its content. Torrent: \"%1\"").arg(removingTorrentDataIter->name)); m_removingTorrents.erase(removingTorrentDataIter); @@ -5425,7 +5428,6 @@ void SessionImpl::handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed #endif const auto removingTorrentDataIter = m_removingTorrents.find(id); - if (removingTorrentDataIter == m_removingTorrents.end()) return; @@ -5435,7 +5437,7 @@ void SessionImpl::handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed // so we remove the directory ourselves Utils::Fs::smartRemoveEmptyFolderTree(removingTorrentDataIter->pathToRemove); - LogMsg(tr("Removed torrent but failed to delete its content. Torrent: \"%1\". Error: \"%2\"") + LogMsg(tr("Removed torrent but failed to delete its content and/or partfile. Torrent: \"%1\". Error: \"%2\"") .arg(removingTorrentDataIter->name, QString::fromLocal8Bit(p->error.message().c_str())) , Log::WARNING); } @@ -5443,6 +5445,7 @@ void SessionImpl::handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed { LogMsg(tr("Removed torrent. Torrent: \"%1\"").arg(removingTorrentDataIter->name)); } + m_removingTorrents.erase(removingTorrentDataIter); }