mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Merge pull request #11235 from glassez/retry-fetch-rss
Allow to retry fetching RSS feeds. Closes #11168
This commit is contained in:
commit
19c70fd659
@ -121,6 +121,8 @@ namespace
|
||||
explicit DownloadHandlerImpl(const Net::DownloadRequest &downloadRequest, QObject *parent);
|
||||
~DownloadHandlerImpl() override;
|
||||
|
||||
void cancel() override;
|
||||
|
||||
QString url() const;
|
||||
const Net::DownloadRequest downloadRequest() const;
|
||||
|
||||
@ -416,6 +418,17 @@ namespace
|
||||
delete m_reply;
|
||||
}
|
||||
|
||||
void DownloadHandlerImpl::cancel()
|
||||
{
|
||||
if (m_reply) {
|
||||
m_reply->abort();
|
||||
}
|
||||
else {
|
||||
setError(errorCodeToString(QNetworkReply::OperationCanceledError));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadHandlerImpl::assignNetworkReply(QNetworkReply *reply)
|
||||
{
|
||||
Q_ASSERT(reply);
|
||||
|
@ -104,6 +104,8 @@ namespace Net
|
||||
public:
|
||||
using QObject::QObject;
|
||||
|
||||
virtual void cancel() = 0;
|
||||
|
||||
signals:
|
||||
void finished(const DownloadResult &result);
|
||||
};
|
||||
@ -118,6 +120,8 @@ namespace Net
|
||||
static void freeInstance();
|
||||
static DownloadManager *instance();
|
||||
|
||||
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
||||
|
||||
template <typename Context, typename Func>
|
||||
void download(const DownloadRequest &downloadRequest, Context context, Func &&slot);
|
||||
|
||||
@ -137,7 +141,6 @@ namespace Net
|
||||
private:
|
||||
explicit DownloadManager(QObject *parent = nullptr);
|
||||
|
||||
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
||||
void applyProxySettings();
|
||||
void handleReplyFinished(const QNetworkReply *reply);
|
||||
|
||||
|
@ -125,11 +125,13 @@ void Feed::markAsRead()
|
||||
|
||||
void Feed::refresh()
|
||||
{
|
||||
if (isLoading()) return;
|
||||
if (isLoading())
|
||||
m_downloadHandler->cancel();
|
||||
|
||||
// NOTE: Should we allow manually refreshing for disabled session?
|
||||
|
||||
Net::DownloadManager::instance()->download(m_url, this, &Feed::handleDownloadFinished);
|
||||
m_downloadHandler = Net::DownloadManager::instance()->download(m_url);
|
||||
connect(m_downloadHandler, &Net::DownloadHandler::finished, this, &Feed::handleDownloadFinished);
|
||||
|
||||
m_isLoading = true;
|
||||
emit stateChanged(this);
|
||||
|
@ -41,6 +41,7 @@ class AsyncFileStorage;
|
||||
|
||||
namespace Net
|
||||
{
|
||||
class DownloadHandler;
|
||||
struct DownloadResult;
|
||||
}
|
||||
|
||||
@ -125,5 +126,6 @@ namespace RSS
|
||||
QString m_dataFileName;
|
||||
QBasicTimer m_savingTimer;
|
||||
bool m_dirty = false;
|
||||
Net::DownloadHandler *m_downloadHandler = nullptr;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user