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
This commit is contained in:
Christophe Dumez
2012-02-19 20:36:01 +02:00
parent dff6b057b9
commit 146cf9a435
7 changed files with 21 additions and 12 deletions

View File

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

View File

@@ -55,15 +55,14 @@ RssFeed::RssFeed(RssFolder* parent, const QString &url): m_parent(parent), m_ico
}
RssFeed::~RssFeed(){
// Saving current articles to hard disk
if(m_refreshed) {
saveItemsToDisk();
}
if(!m_icon.startsWith(":/") && QFile::exists(m_icon))
misc::safeRemove(m_icon);
}
void RssFeed::saveItemsToDisk() {
qDebug() << Q_FUNC_INFO << m_url;
if (!m_refreshed)
return;
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QVariantList old_items;
foreach(const RssArticle &item, m_articles.values()) {
@@ -105,6 +104,7 @@ void RssFeed::refresh() {
}
void RssFeed::removeAllSettings() {
qDebug() << "Removing all settings / history for feed: " << m_url;
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
if (feeds_w_downloader.contains(m_url)) {
@@ -283,13 +283,13 @@ bool RssFeed::parseRSS(QIODevice* device) {
}
}
// Make sure we limit the number of articles
resizeList();
// RSS Feed Downloader
if(RssSettings().isRssDownloadingEnabled())
downloadMatchingArticleTorrents();
// Make sure we limit the number of articles
resizeList();
// Save items to disk (for safety)
saveItemsToDisk();

View File

@@ -48,7 +48,8 @@ public:
FileType type() const;
void refresh();
QString id() const { return m_url; }
void removeAllSettings();
virtual void removeAllSettings();
virtual void saveItemsToDisk();
bool itemAlreadyExists(const QString &hash) const;
void setLoading(bool val);
bool isLoading() const;
@@ -77,7 +78,6 @@ private:
bool parseXmlFile(const QString &file_path);
void downloadMatchingArticleTorrents();
QString iconUrl() const;
void saveItemsToDisk();
void loadItemsFromDisk();
private:

View File

@@ -54,6 +54,7 @@ public:
virtual void setParent(RssFolder* parent) = 0;
virtual void refresh() = 0;
virtual void removeAllSettings() = 0;
virtual void saveItemsToDisk() = 0;
virtual const QList<RssArticle> articleList() const = 0;
virtual const QList<RssArticle> unreadArticleList() const = 0;
QStringList pathHierarchy() const;

View File

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

View File

@@ -59,7 +59,8 @@ public:
bool hasChild(const QString &childId);
const QList<RssArticle> articleList() const;
const QList<RssArticle> unreadArticleList() const;
void removeAllSettings();
virtual void removeAllSettings();
virtual void saveItemsToDisk();
void removeAllItems();
void renameChildFolder(const QString &old_name, const QString &new_name);
IRssFile *takeChild(const QString &childId);

View File

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