mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 19:57:45 +03:00
When resuming a torrent with error, checking if the previous data is present before redownloading it. (closes #609748)
This commit is contained in:
parent
5d1a584eac
commit
aa58636832
3 changed files with 39 additions and 2 deletions
|
@ -2195,7 +2195,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
#endif
|
#endif
|
||||||
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
|
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
|
||||||
if(p->handle.is_valid()) {
|
if(p->handle.is_valid()) {
|
||||||
p->handle.save_resume_data();
|
QTorrentHandle h(p->handle);
|
||||||
|
if(!h.has_error())
|
||||||
|
h.save_resume_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
||||||
|
@ -2281,9 +2283,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
#else
|
#else
|
||||||
if(p->error.value() == 134) {
|
if(p->error.value() == 134) {
|
||||||
#endif
|
#endif
|
||||||
|
const QString hash = h.hash();
|
||||||
// Mismatching file size (files were probably moved
|
// Mismatching file size (files were probably moved
|
||||||
addConsoleMessage(tr("File sizes mismatch for torrent %1, pausing it.").arg(h.name()));
|
addConsoleMessage(tr("File sizes mismatch for torrent %1, pausing it.").arg(h.name()));
|
||||||
pauseTorrent(h.hash());
|
pauseTorrent(hash);
|
||||||
|
TorrentPersistentData::setErrorState(hash, true);
|
||||||
} else {
|
} else {
|
||||||
addConsoleMessage(tr("Fast resume data was rejected for torrent %1, checking again...").arg(h.name()), QString::fromUtf8("red"));
|
addConsoleMessage(tr("Fast resume data was rejected for torrent %1, checking again...").arg(h.name()), QString::fromUtf8("red"));
|
||||||
addConsoleMessage(tr("Reason: %1").arg(misc::toQString(p->message())));
|
addConsoleMessage(tr("Reason: %1").arg(misc::toQString(p->message())));
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "preferences.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
#include "torrentpersistentdata.h"
|
#include "torrentpersistentdata.h"
|
||||||
#include <libtorrent/version.hpp>
|
#include <libtorrent/version.hpp>
|
||||||
|
@ -510,8 +511,24 @@ void QTorrentHandle::pause() {
|
||||||
void QTorrentHandle::resume() {
|
void QTorrentHandle::resume() {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
if(has_error()) h.clear_error();
|
if(has_error()) h.clear_error();
|
||||||
|
const QString torrent_hash = hash();
|
||||||
|
bool has_persistant_error = TorrentPersistentData::hasError(torrent_hash);
|
||||||
|
TorrentPersistentData::setErrorState(torrent_hash, false);
|
||||||
|
bool temp_path_enabled = Preferences::isTempPathEnabled();
|
||||||
|
if(has_persistant_error && temp_path_enabled) {
|
||||||
|
// Torrent was supposed to be seeding, checking again in final destination
|
||||||
|
qDebug("Resuming a torrent with error...");
|
||||||
|
const QString final_save_path = TorrentPersistentData::getSavePath(torrent_hash);
|
||||||
|
qDebug("Torrent final path is: %s", qPrintable(final_save_path));
|
||||||
|
if(!final_save_path.isEmpty())
|
||||||
|
move_storage(final_save_path);
|
||||||
|
}
|
||||||
h.auto_managed(true);
|
h.auto_managed(true);
|
||||||
h.resume();
|
h.resume();
|
||||||
|
if(has_persistant_error && temp_path_enabled) {
|
||||||
|
// Force recheck
|
||||||
|
h.force_recheck();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::remove_url_seed(QString seed) {
|
void QTorrentHandle::remove_url_seed(QString seed) {
|
||||||
|
|
|
@ -227,6 +227,22 @@ public:
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setErrorState(QString hash, bool has_error) {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
|
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||||
|
data.insert("has_error", has_error);
|
||||||
|
all_data[hash] = data;
|
||||||
|
settings.setValue("torrents", all_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasError(QString hash) {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
|
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||||
|
return data.value("has_error", false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
static void setRootFolder(QString hash, QString root_folder) {
|
static void setRootFolder(QString hash, QString root_folder) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
|
|
Loading…
Reference in a new issue