Load torrents that have big metadata file. Closes #1889.

This commit is contained in:
sledgehammer999
2014-11-16 21:25:42 +02:00
parent 0adb9fcbce
commit f35e06540e
5 changed files with 115 additions and 76 deletions

View File

@@ -191,11 +191,16 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString
m_hasMetadata = true;
try {
m_torrentInfo = new torrent_info(fsutils::toNativePath(m_filePath).toUtf8().data());
m_hash = misc::toQString(m_torrentInfo->info_hash());
} catch(const std::exception& e) {
MessageBoxRaised::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1").arg(misc::toQStringU(e.what())));
return false;
std::vector<char> buffer;
lazy_entry entry;
libtorrent::error_code ec;
misc::loadBencodedFile(m_filePath, buffer, entry, ec);
m_torrentInfo = new torrent_info(entry);
m_hash = misc::toQString(m_torrentInfo->info_hash());
}
catch(const std::exception& e) {
MessageBoxRaised::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1").arg(misc::toQStringU(e.what())));
return false;
}
// Prevent showing the dialog if download is already present