mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-29 03:38:05 -06:00
Load torrents that have big metadata file. Closes #1889.
This commit is contained in:
13
src/misc.cpp
13
src/misc.cpp
@@ -77,6 +77,7 @@ const int UNLEN = 256;
|
||||
#include <libtorrent/sha1_hash.hpp>
|
||||
#endif
|
||||
#include <libtorrent/escape_string.hpp>
|
||||
#include <libtorrent/lazy_entry.hpp>
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
@@ -655,6 +656,18 @@ bool misc::slowEquals(const QByteArray &a, const QByteArray &b)
|
||||
return (diff == 0);
|
||||
}
|
||||
|
||||
void misc::loadBencodedFile(const QString &filename, std::vector<char> &buffer, libtorrent::lazy_entry &entry, libtorrent::error_code &ec)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::ReadOnly)) return;
|
||||
const qint64 content_size = file.bytesAvailable();
|
||||
if (content_size <= 0) return;
|
||||
buffer.resize(content_size);
|
||||
file.read(&buffer[0], content_size);
|
||||
// bdecode
|
||||
lazy_bdecode(&buffer[0], &buffer[0] + buffer.size(), entry, ec);
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Trick to get a portable sleep() function
|
||||
class SleeperThread : public QThread {
|
||||
|
||||
Reference in New Issue
Block a user