mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
Show info hash in log when added a duplicate torrent
Closes #22161. PR #22505.
This commit is contained in:
parent
f0b9a17566
commit
ff03eeab5b
8 changed files with 45 additions and 11 deletions
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "addtorrentmanager.h"
|
#include "addtorrentmanager.h"
|
||||||
|
|
||||||
|
#include "base/bittorrent/addtorrenterror.h"
|
||||||
#include "base/bittorrent/infohash.h"
|
#include "base/bittorrent/infohash.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrentdescriptor.h"
|
#include "base/bittorrent/torrentdescriptor.h"
|
||||||
|
@ -185,8 +186,8 @@ void AddTorrentManager::handleDuplicateTorrent(const QString &source
|
||||||
message = tr("Trackers are merged from new source");
|
message = tr("Trackers are merged from new source");
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Source: %1. Existing torrent: %2. Result: %3")
|
LogMsg(tr("Detected an attempt to add a duplicate torrent. Source: %1. Existing torrent: \"%2\". Torrent infohash: %3. Result: %4")
|
||||||
.arg(source, existingTorrent->name(), message));
|
.arg(source, existingTorrent->name(), existingTorrent->infoHash().toString(), message));
|
||||||
emit addTorrentFailed(source, {BitTorrent::AddTorrentError::DuplicateTorrent, message});
|
emit addTorrentFailed(source, {BitTorrent::AddTorrentError::DuplicateTorrent, message});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "base/applicationcomponent.h"
|
#include "base/applicationcomponent.h"
|
||||||
#include "base/bittorrent/addtorrenterror.h"
|
|
||||||
#include "base/bittorrent/addtorrentparams.h"
|
#include "base/bittorrent/addtorrentparams.h"
|
||||||
#include "base/torrentfileguard.h"
|
#include "base/torrentfileguard.h"
|
||||||
|
|
||||||
|
@ -45,6 +44,7 @@ namespace BitTorrent
|
||||||
class Session;
|
class Session;
|
||||||
class Torrent;
|
class Torrent;
|
||||||
class TorrentDescriptor;
|
class TorrentDescriptor;
|
||||||
|
struct AddTorrentError;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Net
|
namespace Net
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#include "infohash.h"
|
#include "infohash.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "base/global.h"
|
||||||
|
|
||||||
const int TorrentIDTypeId = qRegisterMetaType<BitTorrent::TorrentID>();
|
const int TorrentIDTypeId = qRegisterMetaType<BitTorrent::TorrentID>();
|
||||||
|
|
||||||
|
@ -86,6 +89,28 @@ BitTorrent::TorrentID BitTorrent::InfoHash::toTorrentID() const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BitTorrent::InfoHash::toString() const
|
||||||
|
{
|
||||||
|
// Returns a string that is suitable for logging purpose
|
||||||
|
|
||||||
|
QString ret;
|
||||||
|
ret.reserve(40 + 64 + 2); // v1 hash length + v2 hash length + comma
|
||||||
|
|
||||||
|
const SHA1Hash v1Hash = v1();
|
||||||
|
const bool v1IsValid = v1Hash.isValid();
|
||||||
|
if (v1IsValid)
|
||||||
|
ret += v1Hash.toString();
|
||||||
|
|
||||||
|
if (const SHA256Hash v2Hash = v2(); v2Hash.isValid())
|
||||||
|
{
|
||||||
|
if (v1IsValid)
|
||||||
|
ret += u", ";
|
||||||
|
ret += v2Hash.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
BitTorrent::InfoHash::operator WrappedType() const
|
BitTorrent::InfoHash::operator WrappedType() const
|
||||||
{
|
{
|
||||||
return m_nativeHash;
|
return m_nativeHash;
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
#include "base/digest32.h"
|
#include "base/digest32.h"
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
using SHA1Hash = Digest32<160>;
|
using SHA1Hash = Digest32<160>;
|
||||||
using SHA256Hash = Digest32<256>;
|
using SHA256Hash = Digest32<256>;
|
||||||
|
|
||||||
|
@ -79,6 +81,8 @@ namespace BitTorrent
|
||||||
SHA256Hash v2() const;
|
SHA256Hash v2() const;
|
||||||
TorrentID toTorrentID() const;
|
TorrentID toTorrentID() const;
|
||||||
|
|
||||||
|
QString toString() const;
|
||||||
|
|
||||||
operator WrappedType() const;
|
operator WrappedType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2790,8 +2790,8 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
||||||
if (!isMergeTrackersEnabled())
|
if (!isMergeTrackersEnabled())
|
||||||
{
|
{
|
||||||
const QString message = tr("Merging of trackers is disabled");
|
const QString message = tr("Merging of trackers is disabled");
|
||||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||||
.arg(torrent->name(), message));
|
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2800,8 +2800,8 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
||||||
if (isPrivate)
|
if (isPrivate)
|
||||||
{
|
{
|
||||||
const QString message = tr("Trackers cannot be merged because it is a private torrent");
|
const QString message = tr("Trackers cannot be merged because it is a private torrent");
|
||||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||||
.arg(torrent->name(), message));
|
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2811,8 +2811,8 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
||||||
torrent->addUrlSeeds(source.urlSeeds());
|
torrent->addUrlSeeds(source.urlSeeds());
|
||||||
|
|
||||||
const QString message = tr("Trackers are merged from new source");
|
const QString message = tr("Trackers are merged from new source");
|
||||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||||
.arg(torrent->name(), message));
|
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "base/addtorrentmanager.h"
|
#include "base/addtorrentmanager.h"
|
||||||
#include "base/asyncfilestorage.h"
|
#include "base/asyncfilestorage.h"
|
||||||
|
#include "base/bittorrent/addtorrenterror.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrentdescriptor.h"
|
#include "base/bittorrent/torrentdescriptor.h"
|
||||||
#include "base/global.h"
|
#include "base/global.h"
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include "base/applicationcomponent.h"
|
#include "base/applicationcomponent.h"
|
||||||
#include "base/bittorrent/addtorrenterror.h"
|
|
||||||
#include "base/exceptions.h"
|
#include "base/exceptions.h"
|
||||||
#include "base/settingvalue.h"
|
#include "base/settingvalue.h"
|
||||||
#include "base/utils/thread.h"
|
#include "base/utils/thread.h"
|
||||||
|
@ -48,6 +47,11 @@ class Application;
|
||||||
class AsyncFileStorage;
|
class AsyncFileStorage;
|
||||||
struct ProcessingJob;
|
struct ProcessingJob;
|
||||||
|
|
||||||
|
namespace BitTorrent
|
||||||
|
{
|
||||||
|
struct AddTorrentError;
|
||||||
|
}
|
||||||
|
|
||||||
namespace RSS
|
namespace RSS
|
||||||
{
|
{
|
||||||
class Article;
|
class Article;
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrentdescriptor.h"
|
#include "base/bittorrent/torrentdescriptor.h"
|
||||||
#include "base/logger.h"
|
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/torrentfileguard.h"
|
#include "base/torrentfileguard.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue