Skip to content

Commit

Permalink
Merge pull request #13614 from glassez/resumedata
Browse files Browse the repository at this point in the history
Prevent resume data to be saved for removed torrent
  • Loading branch information
glassez authored Oct 23, 2020
2 parents 9ce5416 + 92c6fc0 commit 82602b5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/base/bittorrent/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1788,12 +1788,18 @@ bool Session::deleteTorrent(const InfoHash &hash, const DeleteOption deleteOptio
}

// Remove it from torrent resume directory
const QDir resumeDataDir(m_resumeFolderPath);
QStringList filters;
filters << QString::fromLatin1("%1.*").arg(torrent->hash());
const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted);
for (const QString &file : files)
Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file));
const QString resumedataFile = QString::fromLatin1("%1.fastresume").arg(torrent->hash());
const QString metadataFile = QString::fromLatin1("%1.torrent").arg(torrent->hash());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager, [this, resumedataFile, metadataFile]()
{
m_resumeDataSavingManager->remove(resumedataFile);
m_resumeDataSavingManager->remove(metadataFile);
});
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, resumedataFile));
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, metadataFile));
#endif

delete torrent;
return true;
Expand Down

0 comments on commit 82602b5

Please sign in to comment.