Find complete files when checking torrent

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-04-27 11:26:45 +03:00
parent a1faef0a3c
commit 4a1e3de06d
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
5 changed files with 165 additions and 7 deletions

View file

@ -94,6 +94,7 @@
#include "base/utils/net.h"
#include "base/utils/random.h"
#include "bandwidthscheduler.h"
#include "customstorage.h"
#include "filterparserthread.h"
#include "ltunderlyingtype.h"
#include "magneturi.h"
@ -2456,6 +2457,8 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
p.max_connections = maxConnectionsPerTorrent();
p.max_uploads = maxUploadsPerTorrent();
p.storage = customStorageConstructor;
m_addingTorrents.insert(hash, params);
// Adding torrent to BitTorrent session
m_nativeSession->async_add_torrent(p);
@ -2528,21 +2531,23 @@ bool Session::loadMetadata(const MagnetUri &magnetUri)
const QString savePath = Utils::Fs::tempPath() + static_cast<QString>(hash);
p.save_path = Utils::Fs::toNativePath(savePath).toStdString();
// Forced start
#if (LIBTORRENT_VERSION_NUM < 10200)
// Forced start
p.flags &= ~lt::add_torrent_params::flag_paused;
p.flags &= ~lt::add_torrent_params::flag_auto_managed;
#else
p.flags &= ~lt::torrent_flags::paused;
p.flags &= ~lt::torrent_flags::auto_managed;
#endif
// Solution to avoid accidental file writes
#if (LIBTORRENT_VERSION_NUM < 10200)
p.flags |= lt::add_torrent_params::flag_upload_mode;
#else
// Forced start
p.flags &= ~lt::torrent_flags::paused;
p.flags &= ~lt::torrent_flags::auto_managed;
// Solution to avoid accidental file writes
p.flags |= lt::torrent_flags::upload_mode;
#endif
p.storage = customStorageConstructor;
#endif
// Adding torrent to BitTorrent session
lt::error_code ec;