clear etag values after feed purge
This commit is contained in:
parent
74a50d62e3
commit
2e9d26edc1
5 changed files with 31 additions and 4 deletions
|
@ -61,6 +61,12 @@ void StandardServiceRoot::onDatabaseCleanup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StandardServiceRoot::onAfterFeedsPurged(const QList<Feed*>& feeds) {
|
||||||
|
for (Feed* fd : feeds) {
|
||||||
|
static_cast<StandardFeed*>(fd)->setLastEtag(QString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StandardServiceRoot::start(bool freshly_activated) {
|
void StandardServiceRoot::start(bool freshly_activated) {
|
||||||
DatabaseQueries::loadRootFromDatabase<StandardCategory, StandardFeed>(this);
|
DatabaseQueries::loadRootFromDatabase<StandardCategory, StandardFeed>(this);
|
||||||
|
|
||||||
|
@ -227,7 +233,8 @@ void StandardServiceRoot::spaceHost(const QString& host, const QString& url) {
|
||||||
m_spacingMutex.unlock();
|
m_spacingMutex.unlock();
|
||||||
|
|
||||||
if (secs_to_wait > 0) {
|
if (secs_to_wait > 0) {
|
||||||
qDebugNN << LOGSEC_STANDARD << "Freezing feed with URL" << QUOTE_W_SPACE(url) << "for" << NONQUOTE_W_SPACE(secs_to_wait)
|
qDebugNN << LOGSEC_STANDARD << "Freezing feed with URL" << QUOTE_W_SPACE(url) << "for"
|
||||||
|
<< NONQUOTE_W_SPACE(secs_to_wait)
|
||||||
<< "seconds, because its host was used for fetching another feed during the spacing period.";
|
<< "seconds, because its host was used for fetching another feed during the spacing period.";
|
||||||
QThread::sleep(ulong(secs_to_wait));
|
QThread::sleep(ulong(secs_to_wait));
|
||||||
qDebugNN << LOGSEC_STANDARD << "Freezing feed with URL" << QUOTE_W_SPACE(url) << "is done.";
|
qDebugNN << LOGSEC_STANDARD << "Freezing feed with URL" << QUOTE_W_SPACE(url) << "is done.";
|
||||||
|
@ -319,7 +326,8 @@ QList<Message> StandardServiceRoot::obtainNewMessages(Feed* feed,
|
||||||
feed_contents = StandardFeed::generateFeedFileWithScript(feed->source(), download_timeout);
|
feed_contents = StandardFeed::generateFeedFileWithScript(feed->source(), download_timeout);
|
||||||
}
|
}
|
||||||
catch (const ScriptException& ex) {
|
catch (const ScriptException& ex) {
|
||||||
qCriticalNN << LOGSEC_STANDARD << "Custom script for generating feed file failed:" << QUOTE_W_SPACE_DOT(ex.message());
|
qCriticalNN << LOGSEC_STANDARD
|
||||||
|
<< "Custom script for generating feed file failed:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||||
|
|
||||||
throw FeedFetchException(Feed::Status::OtherError, ex.message());
|
throw FeedFetchException(Feed::Status::OtherError, ex.message());
|
||||||
}
|
}
|
||||||
|
@ -353,7 +361,8 @@ QList<Message> StandardServiceRoot::obtainNewMessages(Feed* feed,
|
||||||
StandardFeed::postProcessFeedFileWithScript(f->postProcessScript(), feed_contents, download_timeout);
|
StandardFeed::postProcessFeedFileWithScript(f->postProcessScript(), feed_contents, download_timeout);
|
||||||
}
|
}
|
||||||
catch (const ScriptException& ex) {
|
catch (const ScriptException& ex) {
|
||||||
qCriticalNN << LOGSEC_STANDARD << "Post-processing script for feed file failed:" << QUOTE_W_SPACE_DOT(ex.message());
|
qCriticalNN << LOGSEC_STANDARD
|
||||||
|
<< "Post-processing script for feed file failed:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||||
|
|
||||||
throw FeedFetchException(Feed::Status::OtherError, ex.message());
|
throw FeedFetchException(Feed::Status::OtherError, ex.message());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ class StandardServiceRoot : public ServiceRoot {
|
||||||
|
|
||||||
virtual FormAccountDetails* accountSetupDialog() const;
|
virtual FormAccountDetails* accountSetupDialog() const;
|
||||||
virtual void onDatabaseCleanup();
|
virtual void onDatabaseCleanup();
|
||||||
|
virtual void onAfterFeedsPurged(const QList<Feed*>& feeds);
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
|
@ -45,7 +46,7 @@ class StandardServiceRoot : public ServiceRoot {
|
||||||
QList<QAction*> getContextMenuForFeed(StandardFeed* feed);
|
QList<QAction*> getContextMenuForFeed(StandardFeed* feed);
|
||||||
|
|
||||||
void spaceHost(const QString& host, const QString& url);
|
void spaceHost(const QString& host, const QString& url);
|
||||||
void resetHostSpacing(const QString& host, const QDateTime &next_dt);
|
void resetHostSpacing(const QString& host, const QDateTime& next_dt);
|
||||||
|
|
||||||
// If set to number > 0, then requests to fetch feeds
|
// If set to number > 0, then requests to fetch feeds
|
||||||
// will be spaced by the given number (in seconds).
|
// will be spaced by the given number (in seconds).
|
||||||
|
|
|
@ -536,6 +536,16 @@ bool FeedsModel::purgeArticles(const QList<Feed*>& feeds) {
|
||||||
bool anything_purged = DatabaseQueries::purgeFeedArticles(database, feeds);
|
bool anything_purged = DatabaseQueries::purgeFeedArticles(database, feeds);
|
||||||
|
|
||||||
if (anything_purged) {
|
if (anything_purged) {
|
||||||
|
QMultiHash<ServiceRoot*, Feed*> feeds_per_root;
|
||||||
|
|
||||||
|
for (auto* fd : feeds) {
|
||||||
|
feeds_per_root.insert(fd->getParentServiceRoot(), fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto* acc : feeds_per_root.uniqueKeys()) {
|
||||||
|
acc->onAfterFeedsPurged(feeds_per_root.values(acc));
|
||||||
|
}
|
||||||
|
|
||||||
reloadCountsOfWholeModel();
|
reloadCountsOfWholeModel();
|
||||||
emit reloadMessageListRequested(false);
|
emit reloadMessageListRequested(false);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1184,6 +1184,10 @@ bool ServiceRoot::onAfterMessagesRestoredFromBin(RootItem* selected_item, const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceRoot::onAfterFeedsPurged(const QList<Feed*>& feeds) {
|
||||||
|
Q_UNUSED(feeds)
|
||||||
|
}
|
||||||
|
|
||||||
CacheForServiceRoot* ServiceRoot::toCache() const {
|
CacheForServiceRoot* ServiceRoot::toCache() const {
|
||||||
return dynamic_cast<CacheForServiceRoot*>(const_cast<ServiceRoot*>(this));
|
return dynamic_cast<CacheForServiceRoot*>(const_cast<ServiceRoot*>(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,9 @@ class RSSGUARD_DLLSPEC ServiceRoot : public RootItem {
|
||||||
// Selected item is naturally recycle bin.
|
// Selected item is naturally recycle bin.
|
||||||
virtual bool onAfterMessagesRestoredFromBin(RootItem* selected_item, const QList<Message>& messages);
|
virtual bool onAfterMessagesRestoredFromBin(RootItem* selected_item, const QList<Message>& messages);
|
||||||
|
|
||||||
|
// Called AFTER articles of these feeds are purged from the database.
|
||||||
|
virtual void onAfterFeedsPurged(const QList<Feed*>& feeds);
|
||||||
|
|
||||||
// Returns the UNIQUE code of the given service.
|
// Returns the UNIQUE code of the given service.
|
||||||
// NOTE: Keep in sync with ServiceEntryRoot::code().
|
// NOTE: Keep in sync with ServiceEntryRoot::code().
|
||||||
virtual QString code() const = 0;
|
virtual QString code() const = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue