mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 23:17:21 -06:00
Handle exception when torrent file cannot be exported
Both `lt::create_torrent` constructor and `lt::create_torrent::generate()` can throw an exception so we need to handle it to prevent the app from crashing.
This commit is contained in:
committed by
Vladimir Golovnev
parent
6070b41c9b
commit
3faa7226e7
@@ -459,9 +459,18 @@ void BitTorrent::DBResumeDataStorage::Worker::store(const TorrentID &id, const L
|
||||
const std::shared_ptr<lt::torrent_info> torrentInfo = std::move(p.ti);
|
||||
if (torrentInfo)
|
||||
{
|
||||
const lt::create_torrent torrentCreator = lt::create_torrent(*torrentInfo);
|
||||
const lt::entry metadata = torrentCreator.generate();
|
||||
lt::bencode(std::back_inserter(bencodedMetadata), metadata);
|
||||
try
|
||||
{
|
||||
const auto torrentCreator = lt::create_torrent(*torrentInfo);
|
||||
const lt::entry metadata = torrentCreator.generate();
|
||||
lt::bencode(std::back_inserter(bencodedMetadata), metadata);
|
||||
}
|
||||
catch (const std::exception &err)
|
||||
{
|
||||
LogMsg(tr("Couldn't save torrent metadata. Error: %1.")
|
||||
.arg(QString::fromLocal8Bit(err.what())), Log::CRITICAL);
|
||||
return;
|
||||
}
|
||||
|
||||
columns.append(DB_COLUMN_METADATA);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user