|
|
@ -2020,7 +2020,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) { |
|
|
|
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) { |
|
|
|
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->message().c_str())), "red"); |
|
|
|
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(misc::toQString(p->message())), "red"); |
|
|
|
//emit UPnPError(QString(p->msg().c_str()));
|
|
|
|
//emit UPnPError(QString(p->msg().c_str()));
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) { |
|
|
|
else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) { |
|
|
@ -2112,15 +2112,15 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} |
|
|
|
} |
|
|
|
if(appendLabelToSavePath) { |
|
|
|
if(appendLabelToSavePath) { |
|
|
|
qDebug("appendLabelToSavePath is true"); |
|
|
|
qDebug("appendLabelToSavePath is true"); |
|
|
|
QString label = TorrentTempData::getLabel(hash); |
|
|
|
const QString &label = TorrentTempData::getLabel(hash); |
|
|
|
if(!label.isEmpty()) { |
|
|
|
if(!label.isEmpty()) { |
|
|
|
QDir save_dir(savePath); |
|
|
|
const QDir &save_dir(savePath); |
|
|
|
if(save_dir.dirName() != label) { |
|
|
|
if(save_dir.dirName() != label) { |
|
|
|
savePath = save_dir.absoluteFilePath(label); |
|
|
|
savePath = save_dir.absoluteFilePath(label); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
qDebug("getSavePath, got save_path from temp data: %s", savePath.toLocal8Bit().data()); |
|
|
|
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
savePath = TorrentPersistentData::getSavePath(hash); |
|
|
|
savePath = TorrentPersistentData::getSavePath(hash); |
|
|
|
if(savePath.isEmpty()) { |
|
|
|
if(savePath.isEmpty()) { |
|
|
@ -2130,7 +2130,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
savePath = defaultSavePath; |
|
|
|
savePath = defaultSavePath; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!fromScanDir && appendLabelToSavePath) { |
|
|
|
if(!fromScanDir && appendLabelToSavePath) { |
|
|
|
QString label = TorrentPersistentData::getLabel(hash); |
|
|
|
const QString &label = TorrentPersistentData::getLabel(hash); |
|
|
|
if(!label.isEmpty()) { |
|
|
|
if(!label.isEmpty()) { |
|
|
|
QDir save_dir(savePath); |
|
|
|
QDir save_dir(savePath); |
|
|
|
if(save_dir.dirName() != label) { |
|
|
|
if(save_dir.dirName() != label) { |
|
|
@ -2138,7 +2138,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
qDebug("getSavePath, got save_path from persistent data: %s", savePath.toLocal8Bit().data()); |
|
|
|
qDebug("getSavePath, got save_path from persistent data: %s", qPrintable(savePath)); |
|
|
|
} |
|
|
|
} |
|
|
|
// Clean path
|
|
|
|
// Clean path
|
|
|
|
savePath = misc::expandPath(savePath); |
|
|
|
savePath = misc::expandPath(savePath); |
|
|
@ -2147,7 +2147,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
QDir saveDir(savePath); |
|
|
|
QDir saveDir(savePath); |
|
|
|
if(!saveDir.exists()) { |
|
|
|
if(!saveDir.exists()) { |
|
|
|
if(!saveDir.mkpath(saveDir.absolutePath())) { |
|
|
|
if(!saveDir.mkpath(saveDir.absolutePath())) { |
|
|
|
std::cerr << "Couldn't create the save directory: " << saveDir.path().toLocal8Bit().data() << "\n"; |
|
|
|
std::cerr << "Couldn't create the save directory: " << qPrintable(saveDir.path()) << "\n"; |
|
|
|
// XXX: Do something else?
|
|
|
|
// XXX: Do something else?
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2180,7 +2180,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
|
|
|
|
|
|
|
|
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) { |
|
|
|
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) { |
|
|
|
//emit aboutToDownloadFromUrl(url);
|
|
|
|
//emit aboutToDownloadFromUrl(url);
|
|
|
|
QUrl qurl = QUrl::fromEncoded(url.toLocal8Bit()); |
|
|
|
const QUrl &qurl = QUrl::fromEncoded(url.toLocal8Bit()); |
|
|
|
if(!save_path.isEmpty()) |
|
|
|
if(!save_path.isEmpty()) |
|
|
|
savepath_fromurl[qurl] = save_path; |
|
|
|
savepath_fromurl[qurl] = save_path; |
|
|
|
url_skippingDlg << qurl; |
|
|
|
url_skippingDlg << qurl; |
|
|
@ -2190,7 +2190,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
|
|
|
|
|
|
|
|
// Add to Bittorrent session the downloaded torrent file
|
|
|
|
// Add to Bittorrent session the downloaded torrent file
|
|
|
|
void Bittorrent::processDownloadedFile(QString url, QString file_path) { |
|
|
|
void Bittorrent::processDownloadedFile(QString url, QString file_path) { |
|
|
|
int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit())); |
|
|
|
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit())); |
|
|
|
if(index < 0) { |
|
|
|
if(index < 0) { |
|
|
|
// Add file to torrent download list
|
|
|
|
// Add file to torrent download list
|
|
|
|
emit newDownloadedTorrent(file_path, url); |
|
|
|
emit newDownloadedTorrent(file_path, url); |
|
|
@ -2204,7 +2204,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
// session. Payload means that it only take into
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// account "useful" part of the rate
|
|
|
|
// account "useful" part of the rate
|
|
|
|
float Bittorrent::getPayloadDownloadRate() const{ |
|
|
|
float Bittorrent::getPayloadDownloadRate() const{ |
|
|
|
session_status sessionStatus = s->status(); |
|
|
|
const session_status &sessionStatus = s->status(); |
|
|
|
return sessionStatus.payload_download_rate; |
|
|
|
return sessionStatus.payload_download_rate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2212,7 +2212,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
// session. Payload means that it only take into
|
|
|
|
// session. Payload means that it only take into
|
|
|
|
// account "useful" part of the rate
|
|
|
|
// account "useful" part of the rate
|
|
|
|
float Bittorrent::getPayloadUploadRate() const{ |
|
|
|
float Bittorrent::getPayloadUploadRate() const{ |
|
|
|
session_status sessionStatus = s->status(); |
|
|
|
const session_status &sessionStatus = s->status(); |
|
|
|
return sessionStatus.payload_upload_rate; |
|
|
|
return sessionStatus.payload_upload_rate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2222,7 +2222,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
if(DHTEnabled) { |
|
|
|
if(DHTEnabled) { |
|
|
|
try{ |
|
|
|
try{ |
|
|
|
entry dht_state = s->dht_state(); |
|
|
|
entry dht_state = s->dht_state(); |
|
|
|
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state")).toLocal8Bit().data(), std::ios_base::binary); |
|
|
|
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state")).toLocal8Bit().constData(), std::ios_base::binary); |
|
|
|
out.unsetf(std::ios_base::skipws); |
|
|
|
out.unsetf(std::ios_base::skipws); |
|
|
|
bencode(std::ostream_iterator<char>(out), dht_state); |
|
|
|
bencode(std::ostream_iterator<char>(out), dht_state); |
|
|
|
qDebug("DHT entry saved"); |
|
|
|
qDebug("DHT entry saved"); |
|
|
@ -2242,8 +2242,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
void Bittorrent::startUpTorrents() { |
|
|
|
void Bittorrent::startUpTorrents() { |
|
|
|
qDebug("Resuming unfinished torrents"); |
|
|
|
qDebug("Resuming unfinished torrents"); |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
QDir torrentBackup(misc::BTBackupLocation()); |
|
|
|
const QDir &torrentBackup(misc::BTBackupLocation()); |
|
|
|
QStringList known_torrents = TorrentPersistentData::knownTorrents(); |
|
|
|
const QStringList &known_torrents = TorrentPersistentData::knownTorrents(); |
|
|
|
|
|
|
|
|
|
|
|
if(known_torrents.empty() && !settings.value("v1_4_x_torrent_imported", false).toBool()) { |
|
|
|
if(known_torrents.empty() && !settings.value("v1_4_x_torrent_imported", false).toBool()) { |
|
|
|
qDebug("No known torrent, importing old torrents"); |
|
|
|
qDebug("No known torrent, importing old torrents"); |
|
|
@ -2255,11 +2255,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
// we switch the v1.5 way of resuming torrents on startup
|
|
|
|
// we switch the v1.5 way of resuming torrents on startup
|
|
|
|
QStringList filters; |
|
|
|
QStringList filters; |
|
|
|
filters << "*.torrent"; |
|
|
|
filters << "*.torrent"; |
|
|
|
QStringList torrents_on_hd = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
|
const QStringList &torrents_on_hd = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
|
foreach(QString hash, torrents_on_hd) { |
|
|
|
foreach(QString hash, torrents_on_hd) { |
|
|
|
hash.chop(8); // remove trailing .torrent
|
|
|
|
hash.chop(8); // remove trailing .torrent
|
|
|
|
if(!known_torrents.contains(hash)) { |
|
|
|
if(!known_torrents.contains(hash)) { |
|
|
|
std::cerr << "ERROR Detected!!! Adding back torrent " << hash.toLocal8Bit().data() << " which got lost for some reason." << std::endl; |
|
|
|
std::cerr << "ERROR Detected!!! Adding back torrent " << qPrintable(hash) << " which got lost for some reason." << std::endl; |
|
|
|
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true); |
|
|
|
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2275,14 +2275,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
filePath = torrentBackup.path()+QDir::separator()+hash+".torrent"; |
|
|
|
filePath = torrentBackup.path()+QDir::separator()+hash+".torrent"; |
|
|
|
} |
|
|
|
} |
|
|
|
int prio = TorrentPersistentData::getPriority(hash); |
|
|
|
const int prio = TorrentPersistentData::getPriority(hash); |
|
|
|
misc::insertSort2<QString>(hashes, qMakePair(prio, hash)); |
|
|
|
misc::insertSort2<QString>(hashes, qMakePair(prio, hash)); |
|
|
|
} |
|
|
|
} |
|
|
|
// Resume downloads
|
|
|
|
// Resume downloads
|
|
|
|
QPair<int, QString> couple; |
|
|
|
QPair<int, QString> couple; |
|
|
|
foreach(couple, hashes) { |
|
|
|
foreach(couple, hashes) { |
|
|
|
QString hash = couple.second; |
|
|
|
const QString &hash = couple.second; |
|
|
|
qDebug("Starting up torrent %s", hash.toLocal8Bit().data()); |
|
|
|
qDebug("Starting up torrent %s", qPrintable(hash)); |
|
|
|
if(TorrentPersistentData::isMagnet(hash)) { |
|
|
|
if(TorrentPersistentData::isMagnet(hash)) { |
|
|
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true); |
|
|
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -2292,7 +2292,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Resume downloads
|
|
|
|
// Resume downloads
|
|
|
|
foreach(const QString &hash, known_torrents) { |
|
|
|
foreach(const QString &hash, known_torrents) { |
|
|
|
qDebug("Starting up torrent %s", hash.toLocal8Bit().data()); |
|
|
|
qDebug("Starting up torrent %s", qPrintable(hash)); |
|
|
|
if(TorrentPersistentData::isMagnet(hash)) |
|
|
|
if(TorrentPersistentData::isMagnet(hash)) |
|
|
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true); |
|
|
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true); |
|
|
|
else |
|
|
|
else |
|
|
@ -2306,10 +2306,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
// TODO: Remove in qBittorrent v2.2.0
|
|
|
|
// TODO: Remove in qBittorrent v2.2.0
|
|
|
|
void Bittorrent::importOldTempData(QString torrent_path) { |
|
|
|
void Bittorrent::importOldTempData(QString torrent_path) { |
|
|
|
// Create torrent hash
|
|
|
|
// Create torrent hash
|
|
|
|
boost::intrusive_ptr<torrent_info> t; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
t = new torrent_info(torrent_path.toLocal8Bit().data()); |
|
|
|
boost::intrusive_ptr<torrent_info> t = new torrent_info(torrent_path.toLocal8Bit().data()); |
|
|
|
QString hash = misc::toQString(t->info_hash()); |
|
|
|
const QString &hash = misc::toQString(t->info_hash()); |
|
|
|
// Load save path
|
|
|
|
// Load save path
|
|
|
|
QFile savepath_file(misc::BTBackupLocation()+QDir::separator()+hash+".savepath"); |
|
|
|
QFile savepath_file(misc::BTBackupLocation()+QDir::separator()+hash+".savepath"); |
|
|
|
QByteArray line; |
|
|
|
QByteArray line; |
|
|
@ -2317,9 +2316,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
line = savepath_file.readAll(); |
|
|
|
line = savepath_file.readAll(); |
|
|
|
savepath_file.close(); |
|
|
|
savepath_file.close(); |
|
|
|
qDebug(" -> Save path: %s", line.data()); |
|
|
|
qDebug(" -> Save path: %s", line.constData()); |
|
|
|
savePath = QString::fromUtf8(line.data()); |
|
|
|
savePath = QString::fromUtf8(line.data()); |
|
|
|
qDebug("Imported the following save path: %s", savePath.toLocal8Bit().data()); |
|
|
|
qDebug("Imported the following save path: %s", qPrintable(savePath)); |
|
|
|
TorrentTempData::setSavePath(hash, savePath); |
|
|
|
TorrentTempData::setSavePath(hash, savePath); |
|
|
|
} |
|
|
|
} |
|
|
|
// Load pieces priority
|
|
|
|
// Load pieces priority
|
|
|
@ -2327,9 +2326,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
if(pieces_file.exists()){ |
|
|
|
if(pieces_file.exists()){ |
|
|
|
// Read saved file
|
|
|
|
// Read saved file
|
|
|
|
if(pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
QByteArray pieces_priorities = pieces_file.readAll(); |
|
|
|
const QByteArray &pieces_priorities = pieces_file.readAll(); |
|
|
|
pieces_file.close(); |
|
|
|
pieces_file.close(); |
|
|
|
QList<QByteArray> pieces_priorities_list = pieces_priorities.split('\n'); |
|
|
|
const QList<QByteArray> &pieces_priorities_list = pieces_priorities.split('\n'); |
|
|
|
std::vector<int> pp; |
|
|
|
std::vector<int> pp; |
|
|
|
for(int i=0; i<t->num_files(); ++i) { |
|
|
|
for(int i=0; i<t->num_files(); ++i) { |
|
|
|
int priority = pieces_priorities_list.at(i).toInt(); |
|
|
|
int priority = pieces_priorities_list.at(i).toInt(); |
|
|
@ -2356,14 +2355,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
// TODO: Remove in qBittorrent v2.2.0
|
|
|
|
// TODO: Remove in qBittorrent v2.2.0
|
|
|
|
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) { |
|
|
|
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) { |
|
|
|
// Load trackers
|
|
|
|
// Load trackers
|
|
|
|
QDir torrentBackup(misc::BTBackupLocation()); |
|
|
|
const QDir &torrentBackup(misc::BTBackupLocation()); |
|
|
|
QFile tracker_file(torrentBackup.path()+QDir::separator()+ h.hash() + ".trackers"); |
|
|
|
QFile tracker_file(torrentBackup.path()+QDir::separator()+ h.hash() + ".trackers"); |
|
|
|
if(tracker_file.exists()) { |
|
|
|
if(tracker_file.exists()) { |
|
|
|
if(tracker_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(tracker_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
QStringList lines = QString::fromUtf8(tracker_file.readAll().data()).split("\n"); |
|
|
|
const QStringList &lines = QString::fromUtf8(tracker_file.readAll().data()).split("\n"); |
|
|
|
std::vector<announce_entry> trackers; |
|
|
|
std::vector<announce_entry> trackers; |
|
|
|
foreach(const QString &line, lines) { |
|
|
|
foreach(const QString &line, lines) { |
|
|
|
QStringList parts = line.split("|"); |
|
|
|
const QStringList &parts = line.split("|"); |
|
|
|
if(parts.size() != 2) continue; |
|
|
|
if(parts.size() != 2) continue; |
|
|
|
announce_entry t(parts[0].toStdString()); |
|
|
|
announce_entry t(parts[0].toStdString()); |
|
|
|
t.tier = parts[1].toInt(); |
|
|
|
t.tier = parts[1].toInt(); |
|
|
@ -2379,13 +2378,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
QFile urlseeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".urlseeds"); |
|
|
|
QFile urlseeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".urlseeds"); |
|
|
|
if(urlseeds_file.exists()) { |
|
|
|
if(urlseeds_file.exists()) { |
|
|
|
if(urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
QByteArray urlseeds_lines = urlseeds_file.readAll(); |
|
|
|
const QByteArray &urlseeds_lines = urlseeds_file.readAll(); |
|
|
|
urlseeds_file.close(); |
|
|
|
urlseeds_file.close(); |
|
|
|
QList<QByteArray> url_seeds = urlseeds_lines.split('\n'); |
|
|
|
const QList<QByteArray> &url_seeds = urlseeds_lines.split('\n'); |
|
|
|
// First remove from the torrent the url seeds that were deleted
|
|
|
|
// First remove from the torrent the url seeds that were deleted
|
|
|
|
// in a previous session
|
|
|
|
// in a previous session
|
|
|
|
QStringList seeds_to_delete; |
|
|
|
QStringList seeds_to_delete; |
|
|
|
QStringList existing_seeds = h.url_seeds(); |
|
|
|
const QStringList &existing_seeds = h.url_seeds(); |
|
|
|
foreach(const QString &existing_seed, existing_seeds) { |
|
|
|
foreach(const QString &existing_seed, existing_seeds) { |
|
|
|
if(!url_seeds.contains(existing_seed.toLocal8Bit())) { |
|
|
|
if(!url_seeds.contains(existing_seed.toLocal8Bit())) { |
|
|
|
seeds_to_delete << existing_seed; |
|
|
|
seeds_to_delete << existing_seed; |
|
|
@ -2408,11 +2407,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
QFile speeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".speedLimits"); |
|
|
|
QFile speeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".speedLimits"); |
|
|
|
if(speeds_file.exists()) { |
|
|
|
if(speeds_file.exists()) { |
|
|
|
if(speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
QByteArray speed_limits = speeds_file.readAll(); |
|
|
|
const QByteArray &speed_limits = speeds_file.readAll(); |
|
|
|
speeds_file.close(); |
|
|
|
speeds_file.close(); |
|
|
|
QList<QByteArray> speeds = speed_limits.split(' '); |
|
|
|
const QList<QByteArray> &speeds = speed_limits.split(' '); |
|
|
|
if(speeds.size() != 2) { |
|
|
|
if(speeds.size() != 2) { |
|
|
|
std::cerr << "Invalid .speedLimits file for " << h.hash().toStdString() << '\n'; |
|
|
|
std::cerr << "Invalid .speedLimits file for " << qPrintable(h.hash()) << '\n'; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
h.set_download_limit(speeds.at(0).toInt()); |
|
|
|
h.set_download_limit(speeds.at(0).toInt()); |
|
|
@ -2427,19 +2426,17 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool()); |
|
|
|
Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool()); |
|
|
|
// Import old torrent
|
|
|
|
// Import old torrent
|
|
|
|
QDir torrentBackup(misc::BTBackupLocation()); |
|
|
|
const QDir &torrentBackup(misc::BTBackupLocation()); |
|
|
|
QStringList fileNames; |
|
|
|
|
|
|
|
QStringList filters; |
|
|
|
QStringList filters; |
|
|
|
filters << "*.torrent"; |
|
|
|
filters << "*.torrent"; |
|
|
|
fileNames = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
|
const QStringList &fileNames = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
|
if(isQueueingEnabled()) { |
|
|
|
if(isQueueingEnabled()) { |
|
|
|
QList<QPair<int, QString> > filePaths; |
|
|
|
QList<QPair<int, QString> > filePaths; |
|
|
|
foreach(const QString &fileName, fileNames) { |
|
|
|
foreach(const QString &fileName, fileNames) { |
|
|
|
QString filePath = torrentBackup.path()+QDir::separator()+fileName; |
|
|
|
QString filePath = torrentBackup.path()+QDir::separator()+fileName; |
|
|
|
int prio = 99999; |
|
|
|
int prio = 99999; |
|
|
|
// Get priority
|
|
|
|
// Get priority
|
|
|
|
QString prioPath = filePath; |
|
|
|
const QString &prioPath = filePath.replace(".torrent", ".prio"); |
|
|
|
prioPath.replace(".torrent", ".prio"); |
|
|
|
|
|
|
|
if(QFile::exists(prioPath)) { |
|
|
|
if(QFile::exists(prioPath)) { |
|
|
|
QFile prio_file(prioPath); |
|
|
|
QFile prio_file(prioPath); |
|
|
|
if(prio_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if(prio_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
@ -2463,12 +2460,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash())); |
|
|
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash())); |
|
|
|
} |
|
|
|
} |
|
|
|
applyFormerAttributeFiles(h); |
|
|
|
applyFormerAttributeFiles(h); |
|
|
|
QString savePath = TorrentTempData::getSavePath(h.hash()); |
|
|
|
const QString &savePath = TorrentTempData::getSavePath(h.hash()); |
|
|
|
// Save persistent data for new torrent
|
|
|
|
// Save persistent data for new torrent
|
|
|
|
TorrentPersistentData::saveTorrentPersistentData(h); |
|
|
|
TorrentPersistentData::saveTorrentPersistentData(h); |
|
|
|
// Save save_path
|
|
|
|
// Save save_path
|
|
|
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) { |
|
|
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) { |
|
|
|
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data()); |
|
|
|
qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath)); |
|
|
|
TorrentPersistentData::saveSavePath(h.hash(), savePath); |
|
|
|
TorrentPersistentData::saveSavePath(h.hash(), savePath); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2487,12 +2484,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { |
|
|
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash())); |
|
|
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash())); |
|
|
|
} |
|
|
|
} |
|
|
|
applyFormerAttributeFiles(h); |
|
|
|
applyFormerAttributeFiles(h); |
|
|
|
QString savePath = TorrentTempData::getSavePath(h.hash()); |
|
|
|
const QString &savePath = TorrentTempData::getSavePath(h.hash()); |
|
|
|
// Save persistent data for new torrent
|
|
|
|
// Save persistent data for new torrent
|
|
|
|
TorrentPersistentData::saveTorrentPersistentData(h); |
|
|
|
TorrentPersistentData::saveTorrentPersistentData(h); |
|
|
|
// Save save_path
|
|
|
|
// Save save_path
|
|
|
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) { |
|
|
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) { |
|
|
|
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data()); |
|
|
|
qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath)); |
|
|
|
TorrentPersistentData::saveSavePath(h.hash(), savePath); |
|
|
|
TorrentPersistentData::saveSavePath(h.hash(), savePath); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|