From 1f3f96f7aab2f29ad07c554fbf5b9ec69d336dad Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Thu, 3 Nov 2022 13:31:17 +0300 Subject: [PATCH] Set metadata asynchronously --- src/base/bittorrent/sessionimpl.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 2219a1892..918a9b79f 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -5759,14 +5759,28 @@ void SessionImpl::handleTorrentConflictAlert(const lt::torrent_conflict_alert *a else cancelDownloadMetadata(torrentIDv1); - torrent2->nativeHandle().set_metadata(a->metadata->info_section()); + invokeAsync([torrentHandle = torrent2->nativeHandle(), metadata = a->metadata] + { + try + { + torrentHandle.set_metadata(metadata->info_section()); + } + catch (const std::exception &) {} + }); } else if (torrent1) { if (!torrent2) cancelDownloadMetadata(torrentIDv2); - torrent1->nativeHandle().set_metadata(a->metadata->info_section()); + invokeAsync([torrentHandle = torrent1->nativeHandle(), metadata = a->metadata] + { + try + { + torrentHandle.set_metadata(metadata->info_section()); + } + catch (const std::exception &) {} + }); } else {