Improve "info hash" handling

Define "torrent ID" concept, which is either a SHA1 hash for torrents of version 1,
or a SHA256 hash (truncated to SHA1 hash length) for torrents of version 2.
Add support for native libtorrent2 info hashes.
This commit is contained in:
Vladimir Golovnev (Glassez) 2021-03-05 12:43:58 +03:00
parent 4da4fb0676
commit 561b597031
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
34 changed files with 463 additions and 320 deletions

View file

@ -958,7 +958,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *co
Preferences *const pref = Preferences::instance();
if (pref->recursiveDownloadDisabled()) return;
const auto torrentHash = torrent->hash();
const auto torrentID = torrent->id();
QMessageBox *confirmBox = new QMessageBox(QMessageBox::Question, tr("Recursive download confirmation")
, tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrent->name())
@ -969,10 +969,10 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *co
const QPushButton *yes = confirmBox->addButton(tr("Yes"), QMessageBox::YesRole);
/*QPushButton *no = */ confirmBox->addButton(tr("No"), QMessageBox::NoRole);
const QPushButton *never = confirmBox->addButton(tr("Never"), QMessageBox::NoRole);
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentHash, yes, never](const QAbstractButton *button)
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentID, yes, never](const QAbstractButton *button)
{
if (button == yes)
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentHash);
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentID);
if (button == never)
Preferences::instance()->disableRecursiveDownload();
});