Browse Source

Provide correct error description in "upload mode"

adaptive-webui-19844
Vladimir Golovnev (Glassez) 3 years ago committed by Vladimir Golovnev (glassez)
parent
commit
6aa8251b98
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 3
      src/base/bittorrent/session.cpp
  2. 16
      src/base/bittorrent/torrentimpl.cpp
  3. 8
      src/base/bittorrent/torrentimpl.h

3
src/base/bittorrent/session.cpp

@ -4580,8 +4580,9 @@ void Session::handleFileErrorAlert(const lt::file_error_alert *p)
if (!torrent) if (!torrent)
return; return;
const TorrentID id = torrent->id(); torrent->handleAlert(p);
const TorrentID id = torrent->id();
if (!m_recentErroredTorrents.contains(id)) if (!m_recentErroredTorrents.contains(id))
{ {
m_recentErroredTorrents.insert(id); m_recentErroredTorrents.insert(id);

16
src/base/bittorrent/torrentimpl.cpp

@ -1005,7 +1005,13 @@ QString TorrentImpl::error() const
return QString::fromStdString(m_nativeStatus.errc.message()); return QString::fromStdString(m_nativeStatus.errc.message());
if (m_nativeStatus.flags & lt::torrent_flags::upload_mode) if (m_nativeStatus.flags & lt::torrent_flags::upload_mode)
return tr("There's not enough space on disk. Torrent is currently in \"upload only\" mode."); {
const QString writeErrorStr = tr("Couldn't write to file.");
const QString uploadModeStr = tr("Torrent is currently in \"upload only\" mode.");
const QString errorMessage = QString::fromLocal8Bit(m_lastFileError.error.message().c_str());
return writeErrorStr + QLatin1Char(' ') + errorMessage + QLatin1String(". ") + uploadModeStr;
}
return {}; return {};
} }
@ -1922,6 +1928,11 @@ void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
} }
} }
void TorrentImpl::handleFileErrorAlert(const lt::file_error_alert *p)
{
m_lastFileError = {p->error, p->op};
}
#if (LIBTORRENT_VERSION_NUM >= 20003) #if (LIBTORRENT_VERSION_NUM >= 20003)
void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *) void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *)
{ {
@ -1981,6 +1992,9 @@ void TorrentImpl::handleAlert(const lt::alert *a)
case lt::file_completed_alert::alert_type: case lt::file_completed_alert::alert_type:
handleFileCompletedAlert(static_cast<const lt::file_completed_alert*>(a)); handleFileCompletedAlert(static_cast<const lt::file_completed_alert*>(a));
break; break;
case lt::file_error_alert::alert_type:
handleFileErrorAlert(static_cast<const lt::file_error_alert*>(a));
break;
case lt::torrent_finished_alert::alert_type: case lt::torrent_finished_alert::alert_type:
handleTorrentFinishedAlert(static_cast<const lt::torrent_finished_alert*>(a)); handleTorrentFinishedAlert(static_cast<const lt::torrent_finished_alert*>(a));
break; break;

8
src/base/bittorrent/torrentimpl.h

@ -78,6 +78,12 @@ namespace BitTorrent
HandleMetadata HandleMetadata
}; };
struct FileErrorInfo
{
lt::error_code error;
lt::operation_t operation;
};
class TorrentImpl final : public QObject, public Torrent class TorrentImpl final : public QObject, public Torrent
{ {
Q_DISABLE_COPY(TorrentImpl) Q_DISABLE_COPY(TorrentImpl)
@ -255,6 +261,7 @@ namespace BitTorrent
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p); void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
void handleFileCompletedAlert(const lt::file_completed_alert *p); void handleFileCompletedAlert(const lt::file_completed_alert *p);
void handleFileErrorAlert(const lt::file_error_alert *p);
#if (LIBTORRENT_VERSION_NUM >= 20003) #if (LIBTORRENT_VERSION_NUM >= 20003)
void handleFilePrioAlert(const lt::file_prio_alert *p); void handleFilePrioAlert(const lt::file_prio_alert *p);
#endif #endif
@ -310,6 +317,7 @@ namespace BitTorrent
QHash<lt::file_index_t, QVector<QString>> m_oldPath; QHash<lt::file_index_t, QVector<QString>> m_oldPath;
QHash<QString, QMap<lt::tcp::endpoint, int>> m_trackerPeerCounts; QHash<QString, QMap<lt::tcp::endpoint, int>> m_trackerPeerCounts;
FileErrorInfo m_lastFileError;
// Persistent data // Persistent data
QString m_name; QString m_name;

Loading…
Cancel
Save