|
|
@ -147,9 +147,10 @@ void bittorrent::deleteBigRatios() { |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::setDownloadLimit(QString hash, long val) { |
|
|
|
void bittorrent::setDownloadLimit(QString hash, long val) { |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
if(h.is_valid()) |
|
|
|
if(h.is_valid()) { |
|
|
|
h.set_download_limit(val); |
|
|
|
h.set_download_limit(val); |
|
|
|
saveTorrentSpeedLimits(hash); |
|
|
|
TorrentPersistentData::saveSpeedLimits(h); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool bittorrent::isQueueingEnabled() const { |
|
|
|
bool bittorrent::isQueueingEnabled() const { |
|
|
@ -172,9 +173,10 @@ void bittorrent::decreaseDlTorrentPriority(QString hash) { |
|
|
|
void bittorrent::setUploadLimit(QString hash, long val) { |
|
|
|
void bittorrent::setUploadLimit(QString hash, long val) { |
|
|
|
qDebug("Set upload limit rate to %ld", val); |
|
|
|
qDebug("Set upload limit rate to %ld", val); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
if(h.is_valid()) |
|
|
|
if(h.is_valid()) { |
|
|
|
h.set_upload_limit(val); |
|
|
|
h.set_upload_limit(val); |
|
|
|
saveTorrentSpeedLimits(hash); |
|
|
|
TorrentPersistentData::saveSpeedLimits(h); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::handleDownloadFailure(QString url, QString reason) { |
|
|
|
void bittorrent::handleDownloadFailure(QString url, QString reason) { |
|
|
@ -821,36 +823,11 @@ bool bittorrent::enableDHT(bool b) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::saveTorrentSpeedLimits(QString hash) { |
|
|
|
|
|
|
|
qDebug("Saving speedLimits file for %s", hash.toLocal8Bit().data()); |
|
|
|
|
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
|
|
|
|
int download_limit = h.download_limit(); |
|
|
|
|
|
|
|
int upload_limit = h.upload_limit(); |
|
|
|
|
|
|
|
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits"); |
|
|
|
|
|
|
|
if(!speeds_file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
|
|
|
|
|
|
|
qDebug("* Error: Couldn't open speed limits file for torrent: %s", hash.toLocal8Bit().data()); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
speeds_file.write(misc::toQByteArray(download_limit)+QByteArray(" ")+misc::toQByteArray(upload_limit)); |
|
|
|
|
|
|
|
speeds_file.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::loadTorrentSpeedLimits(QString hash) { |
|
|
|
void bittorrent::loadTorrentSpeedLimits(QString hash) { |
|
|
|
// qDebug("Loading speedLimits file for %s", hash.toLocal8Bit().data());
|
|
|
|
|
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits"); |
|
|
|
qDebug("Loading speedLimits file for %s", hash.toLocal8Bit().data()); |
|
|
|
if(!speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
h.set_download_limit(TorrentPersistentData::getDownloadLimit(hash)); |
|
|
|
return; |
|
|
|
h.set_upload_limit(TorrentPersistentData::getUploadLimit(hash)); |
|
|
|
} |
|
|
|
|
|
|
|
QByteArray speed_limits = speeds_file.readAll(); |
|
|
|
|
|
|
|
speeds_file.close(); |
|
|
|
|
|
|
|
QList<QByteArray> speeds = speed_limits.split(' '); |
|
|
|
|
|
|
|
if(speeds.size() != 2) { |
|
|
|
|
|
|
|
std::cerr << "Invalid .speedLimits file for " << hash.toStdString() << '\n'; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
h.set_download_limit(speeds.at(0).toInt()); |
|
|
|
|
|
|
|
h.set_upload_limit(speeds.at(1).toInt()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Read pieces priorities from hard disk
|
|
|
|
// Read pieces priorities from hard disk
|
|
|
@ -1674,6 +1651,22 @@ void bittorrent::applyFormerAttributeFiles(QTorrentHandle h) { |
|
|
|
} |
|
|
|
} |
|
|
|
urlseeds_file.remove(); |
|
|
|
urlseeds_file.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Load speed limits
|
|
|
|
|
|
|
|
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+h.hash()+".speedLimits"); |
|
|
|
|
|
|
|
if(speeds_file.exists()) { |
|
|
|
|
|
|
|
if(speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
|
|
|
|
QByteArray speed_limits = speeds_file.readAll(); |
|
|
|
|
|
|
|
speeds_file.close(); |
|
|
|
|
|
|
|
QList<QByteArray> speeds = speed_limits.split(' '); |
|
|
|
|
|
|
|
if(speeds.size() != 2) { |
|
|
|
|
|
|
|
std::cerr << "Invalid .speedLimits file for " << h.hash().toStdString() << '\n'; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
h.set_download_limit(speeds.at(0).toInt()); |
|
|
|
|
|
|
|
h.set_upload_limit(speeds.at(1).toInt()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
speeds_file.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Import torrents from v1.4.0 or earlier
|
|
|
|
// Import torrents from v1.4.0 or earlier
|
|
|
|