clear etag values after feed purge

This commit is contained in:
Martin Rotter 2025-04-16 10:42:23 +02:00
parent 74a50d62e3
commit 2e9d26edc1
5 changed files with 31 additions and 4 deletions

View file

@ -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) {
DatabaseQueries::loadRootFromDatabase<StandardCategory, StandardFeed>(this);
@ -227,7 +233,8 @@ void StandardServiceRoot::spaceHost(const QString& host, const QString& url) {
m_spacingMutex.unlock();
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.";
QThread::sleep(ulong(secs_to_wait));
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);
}
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());
}
@ -353,7 +361,8 @@ QList<Message> StandardServiceRoot::obtainNewMessages(Feed* feed,
StandardFeed::postProcessFeedFileWithScript(f->postProcessScript(), feed_contents, download_timeout);
}
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());
}

View file

@ -27,6 +27,7 @@ class StandardServiceRoot : public ServiceRoot {
virtual FormAccountDetails* accountSetupDialog() const;
virtual void onDatabaseCleanup();
virtual void onAfterFeedsPurged(const QList<Feed*>& feeds);
virtual void start(bool freshly_activated);
virtual void stop();
virtual QString code() const;

View file

@ -536,6 +536,16 @@ bool FeedsModel::purgeArticles(const QList<Feed*>& feeds) {
bool anything_purged = DatabaseQueries::purgeFeedArticles(database, feeds);
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();
emit reloadMessageListRequested(false);
return true;

View file

@ -1184,6 +1184,10 @@ bool ServiceRoot::onAfterMessagesRestoredFromBin(RootItem* selected_item, const
return true;
}
void ServiceRoot::onAfterFeedsPurged(const QList<Feed*>& feeds) {
Q_UNUSED(feeds)
}
CacheForServiceRoot* ServiceRoot::toCache() const {
return dynamic_cast<CacheForServiceRoot*>(const_cast<ServiceRoot*>(this));
}

View file

@ -189,6 +189,9 @@ class RSSGUARD_DLLSPEC ServiceRoot : public RootItem {
// Selected item is naturally recycle bin.
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.
// NOTE: Keep in sync with ServiceEntryRoot::code().
virtual QString code() const = 0;