Browse Source

Safer error detection

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
d2b41d70c8
  1. 6
      src/bittorrent.cpp
  2. 8
      src/qtorrenthandle.cpp
  3. 1
      src/qtorrenthandle.h

6
src/bittorrent.cpp

@ -2357,13 +2357,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -2357,13 +2357,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid() && TorrentPersistentData::isSeed(h.hash())){
if(h.is_valid()) {
qDebug("/!\\ Fast resume failed for %s, reason: %s", qPrintable(h.name()), p->message().c_str());
#if LIBTORRENT_VERSION_MINOR < 15
QString msg = QString::fromLocal8Bit(p->message().c_str());
if(msg.contains("filesize", Qt::CaseInsensitive) && msg.contains("mismatch", Qt::CaseInsensitive)) {
if(msg.contains("filesize", Qt::CaseInsensitive) && msg.contains("mismatch", Qt::CaseInsensitive) && TorrentPersistentData::isSeed(h.hash()) && h.has_missing_files()) {
#else
if(p->error.value() == 134) {
if(p->error.value() == 134 && TorrentPersistentData::isSeed(h.hash()) && h.has_missing_files()) {
#endif
const QString hash = h.hash();
// Mismatching file size (files were probably moved

8
src/qtorrenthandle.cpp

@ -387,6 +387,14 @@ QStringList QTorrentHandle::files_path() const { @@ -387,6 +387,14 @@ QStringList QTorrentHandle::files_path() const {
return res;
}
bool QTorrentHandle::has_missing_files() const {
const QStringList paths = files_path();
foreach(const QString &path, paths) {
if(!QFile::exists(path)) return true;
}
return false;
}
int QTorrentHandle::queue_position() const {
Q_ASSERT(h.is_valid());
if(h.queue_position() < 0)

1
src/qtorrenthandle.h

@ -110,6 +110,7 @@ class QTorrentHandle { @@ -110,6 +110,7 @@ class QTorrentHandle {
size_type all_time_download() const;
size_type total_done() const;
QStringList files_path() const;
bool has_missing_files() const;
int num_uploads() const;
bool is_seed() const;
bool is_checking() const;

Loading…
Cancel
Save