Browse Source

Several RSS fixes:

- Fix possible redownload of torrents marked as read (Closes #927495)
- Properly remove RSS feed settings/history upon feed removal
- Fix possible crash in RSS Downloader dialog in debug mode
adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
b78d6ba243
  1. 3
      src/rss/automatedrssdownloader.cpp
  2. 14
      src/rss/rssfeed.cpp
  3. 2
      src/rss/rssfeed.h
  4. 1
      src/rss/rssfile.h
  5. 7
      src/rss/rssfolder.cpp
  6. 1
      src/rss/rssfolder.h
  7. 1
      src/rss/rssmanager.cpp

3
src/rss/automatedrssdownloader.cpp

@ -474,8 +474,7 @@ void AutomatedRssDownloader::updateMatchingArticles()
if(!rule) continue; if(!rule) continue;
foreach(const QString &feed_url, rule->rssFeeds()) { foreach(const QString &feed_url, rule->rssFeeds()) {
qDebug() << Q_FUNC_INFO << feed_url; qDebug() << Q_FUNC_INFO << feed_url;
Q_ASSERT(all_feeds.contains(feed_url)); if(!all_feeds.contains(feed_url)) continue; // Feed was removed
if(!all_feeds.contains(feed_url)) continue;
RssFeedPtr feed = all_feeds.value(feed_url); RssFeedPtr feed = all_feeds.value(feed_url);
Q_ASSERT(feed); Q_ASSERT(feed);
if(!feed) continue; if(!feed) continue;

14
src/rss/rssfeed.cpp

@ -56,15 +56,14 @@ RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url):
} }
RssFeed::~RssFeed(){ RssFeed::~RssFeed(){
// Saving current articles to hard disk
if(m_refreshed) {
saveItemsToDisk();
}
if(!m_icon.startsWith(":/") && QFile::exists(m_icon)) if(!m_icon.startsWith(":/") && QFile::exists(m_icon))
QFile::remove(m_icon); QFile::remove(m_icon);
} }
void RssFeed::saveItemsToDisk() { void RssFeed::saveItemsToDisk() {
qDebug() << Q_FUNC_INFO << m_url;
if (!m_refreshed)
return;
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QVariantList old_items; QVariantList old_items;
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) { for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
@ -102,6 +101,7 @@ void RssFeed::refresh() {
} }
void RssFeed::removeAllSettings() { void RssFeed::removeAllSettings() {
qDebug() << "Removing all settings / history for feed: " << m_url;
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss"); QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash(); QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
if (feeds_w_downloader.contains(m_url)) { if (feeds_w_downloader.contains(m_url)) {
@ -278,13 +278,13 @@ bool RssFeed::parseRSS(QIODevice* device) {
} }
} }
// Make sure we limit the number of articles
resizeList();
// RSS Feed Downloader // RSS Feed Downloader
if(RssSettings().isRssDownloadingEnabled()) if(RssSettings().isRssDownloadingEnabled())
downloadMatchingArticleTorrents(); downloadMatchingArticleTorrents();
// Make sure we limit the number of articles
resizeList();
// Save items to disk (for safety) // Save items to disk (for safety)
saveItemsToDisk(); saveItemsToDisk();

2
src/rss/rssfeed.h

@ -55,6 +55,7 @@ public:
QString id() const { return m_url; } QString id() const { return m_url; }
void removeAllSettings(); void removeAllSettings();
bool itemAlreadyExists(const QString &guid) const; bool itemAlreadyExists(const QString &guid) const;
virtual void saveItemsToDisk();
void setLoading(bool val); void setLoading(bool val);
bool isLoading() const; bool isLoading() const;
QString title() const; QString title() const;
@ -82,7 +83,6 @@ private:
bool parseXmlFile(const QString &file_path); bool parseXmlFile(const QString &file_path);
void downloadMatchingArticleTorrents(); void downloadMatchingArticleTorrents();
QString iconUrl() const; QString iconUrl() const;
void saveItemsToDisk();
void loadItemsFromDisk(); void loadItemsFromDisk();
private: private:

1
src/rss/rssfile.h

@ -62,6 +62,7 @@ public:
virtual void removeAllSettings() = 0; virtual void removeAllSettings() = 0;
virtual const RssArticleList articleList() const = 0; virtual const RssArticleList articleList() const = 0;
virtual const RssArticleList unreadArticleList() const = 0; virtual const RssArticleList unreadArticleList() const = 0;
virtual void saveItemsToDisk() = 0;
QStringList pathHierarchy() const; QStringList pathHierarchy() const;
}; };

7
src/rss/rssfolder.cpp

@ -184,6 +184,13 @@ void RssFolder::removeAllSettings() {
} }
} }
void RssFolder::saveItemsToDisk()
{
foreach(const RssFilePtr& child, m_children.values()) {
child->saveItemsToDisk();
}
}
QString RssFolder::id() const { QString RssFolder::id() const {
return m_name; return m_name;
} }

1
src/rss/rssfolder.h

@ -65,6 +65,7 @@ public:
const RssArticleList articleList() const; const RssArticleList articleList() const;
const RssArticleList unreadArticleList() const; const RssArticleList unreadArticleList() const;
void removeAllSettings(); void removeAllSettings();
virtual void saveItemsToDisk();
void removeAllItems(); void removeAllItems();
void renameChildFolder(const QString &old_name, const QString &new_name); void renameChildFolder(const QString &old_name, const QString &new_name);
RssFilePtr takeChild(const QString &childId); RssFilePtr takeChild(const QString &childId);

1
src/rss/rssmanager.cpp

@ -48,6 +48,7 @@ RssManager::~RssManager(){
m_refreshTimer.stop(); m_refreshTimer.stop();
delete m_rssDownloader; delete m_rssDownloader;
RssDownloadRuleList::drop(); RssDownloadRuleList::drop();
saveItemsToDisk();
saveStreamList(); saveStreamList();
qDebug("RSSManager deleted"); qDebug("RSSManager deleted");
} }

Loading…
Cancel
Save