From ad7c9ace507b2dab4cf8a7cd6a2ba5dd8821f547 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 18 Aug 2012 21:26:22 +0300 Subject: [PATCH] Do not save RSS feed to disk unless it has changed. Stop to address issue #34. --- src/rss/rssfeed.cpp | 9 ++++++--- src/rss/rssfeed.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rss/rssfeed.cpp b/src/rss/rssfeed.cpp index fa133aee2..611c2eb00 100644 --- a/src/rss/rssfeed.cpp +++ b/src/rss/rssfeed.cpp @@ -43,7 +43,7 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url): m_manager(manager), m_parent(parent), m_icon(":/Icons/oxygen/application-rss+xml.png"), - m_refreshed(false), m_inErrorState(false), m_loading(false) { + m_dirty(false), m_inErrorState(false), m_loading(false) { qDebug() << Q_FUNC_INFO << url; m_url = QUrl::fromEncoded(url.toUtf8()).toString(); // Listen for new RSS downloads @@ -68,8 +68,10 @@ RssFeed::~RssFeed() { void RssFeed::saveItemsToDisk() { qDebug() << Q_FUNC_INFO << m_url; - if (!m_refreshed) + if (!m_dirty) return; + m_dirty = false; + QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); QVariantList old_items; @@ -273,12 +275,13 @@ void RssFeed::handleNewArticle(const QString& feedUrl, const QVariantHash& artic { if (feedUrl != m_url) return; - m_refreshed = true; const QString guid = articleData["id"].toString(); if (m_articles.contains(guid)) return; + m_dirty = true; + RssArticlePtr article = hashToRssArticle(this, articleData); Q_ASSERT(article); m_articles[guid] = article; diff --git a/src/rss/rssfeed.h b/src/rss/rssfeed.h index eeb7fd522..332bf8135 100644 --- a/src/rss/rssfeed.h +++ b/src/rss/rssfeed.h @@ -96,7 +96,7 @@ private: QString m_icon; QString m_iconUrl; bool m_read; - bool m_refreshed; + bool m_dirty; bool m_inErrorState; bool m_loading;