mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
Optimize converter between QString and sha1_hash
This commit is contained in:
parent
de4559659d
commit
0d0c7559bf
10
src/misc.h
10
src/misc.h
@ -73,13 +73,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline QString toQString(const libtorrent::sha1_hash &hash) {
|
static inline QString toQString(const libtorrent::sha1_hash &hash) {
|
||||||
std::ostringstream o;
|
char out[41];
|
||||||
o << hash;
|
to_hex((char const*)&hash[0], libtorrent::sha1_hash::size, out);
|
||||||
return QString(o.str().c_str());
|
return QString(out);
|
||||||
}
|
|
||||||
|
|
||||||
static inline libtorrent::sha1_hash toSha1Hash(const QString &hash) {
|
|
||||||
return libtorrent::sha1_hash(hash.toAscii().constData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chmod644(const QDir& folder);
|
static void chmod644(const QDir& folder);
|
||||||
|
@ -909,7 +909,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) {
|
|||||||
Q_ASSERT(magnet_uri.startsWith("magnet:", Qt::CaseInsensitive));
|
Q_ASSERT(magnet_uri.startsWith("magnet:", Qt::CaseInsensitive));
|
||||||
|
|
||||||
// Check for duplicate torrent
|
// Check for duplicate torrent
|
||||||
if(s->find_torrent(misc::toSha1Hash(hash)).is_valid()) {
|
if(s->find_torrent(QStringToSha1(hash)).is_valid()) {
|
||||||
qDebug("/!\\ Torrent is already in download list");
|
qDebug("/!\\ Torrent is already in download list");
|
||||||
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(magnet_uri));
|
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(magnet_uri));
|
||||||
return h;
|
return h;
|
||||||
|
Loading…
Reference in New Issue
Block a user