From 78c549f83e25835efd74ee1c8bf4f8c76ab33595 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Fri, 28 Jun 2024 07:14:19 +0300 Subject: [PATCH] Use custom storage when reloading torrent PR #20998. --- src/base/bittorrent/customstorage.cpp | 4 ++-- src/base/bittorrent/torrentimpl.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/customstorage.cpp b/src/base/bittorrent/customstorage.cpp index c4957ef07..9134b1507 100644 --- a/src/base/bittorrent/customstorage.cpp +++ b/src/base/bittorrent/customstorage.cpp @@ -240,11 +240,11 @@ void CustomDiskIOThread::handleCompleteFiles(lt::storage_index_t storage, const lt::storage_interface *customStorageConstructor(const lt::storage_params ¶ms, lt::file_pool &pool) { - return new CustomStorage {params, pool}; + return new CustomStorage(params, pool); } CustomStorage::CustomStorage(const lt::storage_params ¶ms, lt::file_pool &filePool) - : lt::default_storage {params, filePool} + : lt::default_storage(params, filePool) , m_savePath {params.path} { } diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index d98e5f4e1..d4638e3c8 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -77,6 +77,10 @@ #include "base/utils/os.h" #endif // Q_OS_MACOS || Q_OS_WIN +#ifndef QBT_USES_LIBTORRENT2 +#include "customstorage.h" +#endif + using namespace BitTorrent; namespace @@ -1860,6 +1864,9 @@ void TorrentImpl::reload() auto *const extensionData = new ExtensionData; p.userdata = LTClientData(extensionData); +#ifndef QBT_USES_LIBTORRENT2 + p.storage = customStorageConstructor; +#endif m_nativeHandle = m_nativeSession->add_torrent(p); m_nativeStatus = extensionData->status;