From d4554c2e5c1fb0cdabd37e317a67b532c5987442 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 20 Apr 2021 17:41:55 +0300 Subject: [PATCH] Correctly handle "no enough disk space" error If torrent failed to write, it stops downloading and goes to "upload mode" instead of errored state so it just keeps seeding. Now qBittorrent indicates this state as "errored" and allows the user to manually bring the torrent out of this state. --- src/base/bittorrent/torrentimpl.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index f653b7f71..4a687e590 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -948,7 +948,7 @@ bool TorrentImpl::hasMissingFiles() const bool TorrentImpl::hasError() const { - return static_cast(m_nativeStatus.errc); + return (m_nativeStatus.errc || (m_nativeStatus.flags & lt::torrent_flags::upload_mode)); } bool TorrentImpl::hasFilteredPieces() const @@ -967,7 +967,13 @@ int TorrentImpl::queuePosition() const QString TorrentImpl::error() const { - return QString::fromStdString(m_nativeStatus.errc.message()); + if (m_nativeStatus.errc) + return QString::fromStdString(m_nativeStatus.errc.message()); + + 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."); + + return {}; } qlonglong TorrentImpl::totalDownload() const @@ -1527,7 +1533,10 @@ void TorrentImpl::pause() void TorrentImpl::resume(const TorrentOperatingMode mode) { if (hasError()) + { m_nativeHandle.clear_error(); + m_nativeHandle.unset_flags(lt::torrent_flags::upload_mode); + } m_operatingMode = mode; @@ -1770,6 +1779,9 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params ¶ms) m_ltAddTorrentParams.added_time = addedTime().toSecsSinceEpoch(); + // We shouldn't save upload_mode flag to allow torrent operate normally on next run + m_ltAddTorrentParams.flags &= ~lt::torrent_flags::upload_mode; + LoadTorrentParams resumeData; resumeData.name = m_name; resumeData.category = m_category;