diff --git a/localization/rssguard_en.ts b/localization/rssguard_en.ts
index db2caaeac..2be5545f8 100644
--- a/localization/rssguard_en.ts
+++ b/localization/rssguard_en.ts
@@ -7486,17 +7486,17 @@ Also, you can post-process generated feed data with yet another script if you wi
Error when loading initial feeds
-
+
Fetch metadata
Fetch metadata
-
+
Export feeds
Export feeds
-
+
Import feeds
Import feeds
@@ -7521,22 +7521,22 @@ Also, you can post-process generated feed data with yet another script if you wi
Cannot add feed because another critical operation is ongoing.
-
+
Cannot add category
Cannot add category
-
+
Cannot add category because another critical operation is ongoing.
Cannot add category because another critical operation is ongoing.
-
+
Import was completely successful.
-
+
Some feeds/categories were not imported due to error, check debug log for more details.
diff --git a/src/librssguard/core/feedsmodel.cpp b/src/librssguard/core/feedsmodel.cpp
index 8215b4205..90138f5e0 100644
--- a/src/librssguard/core/feedsmodel.cpp
+++ b/src/librssguard/core/feedsmodel.cpp
@@ -392,6 +392,12 @@ void FeedsModel::setupFonts() {
m_boldStrikedFont.setStrikeOut(true);
}
+void FeedsModel::informAboutDatabaseCleanup() {
+ for (ServiceRoot* acc : serviceRoots()) {
+ acc->onDatabaseCleanup();
+ }
+}
+
void FeedsModel::reloadWholeLayout() {
emit layoutAboutToBeChanged();
emit layoutChanged();
diff --git a/src/librssguard/core/feedsmodel.h b/src/librssguard/core/feedsmodel.h
index 4a0a59cef..3a8f06851 100644
--- a/src/librssguard/core/feedsmodel.h
+++ b/src/librssguard/core/feedsmodel.h
@@ -79,6 +79,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
RootItem* rootItem() const;
void setupFonts();
+ void informAboutDatabaseCleanup();
public slots:
void loadActivatedServiceAccounts();
diff --git a/src/librssguard/gui/dialogs/formmain.cpp b/src/librssguard/gui/dialogs/formmain.cpp
index 48d1e5e41..68bb9aa31 100644
--- a/src/librssguard/gui/dialogs/formmain.cpp
+++ b/src/librssguard/gui/dialogs/formmain.cpp
@@ -145,6 +145,7 @@ void FormMain::showDbCleanupAssistant() {
// Reload needed stuff.
qApp->feedUpdateLock()->unlock();
tabWidget()->feedMessageViewer()->messagesView()->reloadSelections();
+ qApp->feedReader()->feedsModel()->informAboutDatabaseCleanup();
qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel();
}
else {
diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp
index 09e9da7e9..b2a8f2293 100644
--- a/src/librssguard/services/abstract/serviceroot.cpp
+++ b/src/librssguard/services/abstract/serviceroot.cpp
@@ -479,6 +479,8 @@ UnreadNode* ServiceRoot::unreadNode() const {
return m_unreadNode;
}
+void ServiceRoot::onDatabaseCleanup() {}
+
void ServiceRoot::syncIn() {
QIcon original_icon = icon();
diff --git a/src/librssguard/services/abstract/serviceroot.h b/src/librssguard/services/abstract/serviceroot.h
index 6b3a1e7d5..0aeac09f1 100644
--- a/src/librssguard/services/abstract/serviceroot.h
+++ b/src/librssguard/services/abstract/serviceroot.h
@@ -59,6 +59,7 @@ class ServiceRoot : public RootItem {
SearchsNode* probesNode() const;
UnreadNode* unreadNode() const;
+ virtual void onDatabaseCleanup();
virtual void updateCounts(bool including_total_count);
virtual bool canBeDeleted() const;
virtual bool deleteViaGui();
diff --git a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp
index c609ec3d6..45e97d833 100644
--- a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp
+++ b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp
@@ -81,6 +81,7 @@ void FormStandardFeedDetails::apply() {
std_feed->setIcon(m_standardFeedDetails->m_ui.m_btnIcon->icon());
std_feed->setSource(m_standardFeedDetails->m_ui.m_txtSource->textEdit()->toPlainText());
+ std_feed->setLastEtag({});
std_feed->setEncoding(m_standardFeedDetails->m_ui.m_cmbEncoding->currentText());
std_feed->setType(type);
diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp
index 2954768cd..8c5c9c422 100644
--- a/src/librssguard/services/standard/standardfeed.cpp
+++ b/src/librssguard/services/standard/standardfeed.cpp
@@ -40,11 +40,11 @@
StandardFeed::StandardFeed(RootItem* parent_item) : Feed(parent_item) {
m_type = Type::Rss0X;
m_sourceType = SourceType::Url;
- m_encoding = m_postProcessScript = QString();
+ m_encoding = m_postProcessScript = {};
m_protection = NetworkFactory::NetworkAuthentication::NoAuthentication;
- m_username = QString();
- m_password = QString();
+ m_username = {};
+ m_password = {};
}
StandardFeed::StandardFeed(const StandardFeed& other) : Feed(other) {
@@ -386,6 +386,14 @@ bool StandardFeed::removeItself() {
return DatabaseQueries::deleteFeed(database, this, getParentServiceRoot()->accountId());
}
+QString StandardFeed::lastEtag() const {
+ return m_lastEtag;
+}
+
+void StandardFeed::setLastEtag(const QString& etag) {
+ m_lastEtag = etag;
+}
+
StandardFeed::Type StandardFeed::type() const {
return m_type;
}
diff --git a/src/librssguard/services/standard/standardfeed.h b/src/librssguard/services/standard/standardfeed.h
index f29ff830c..755cbdbc0 100644
--- a/src/librssguard/services/standard/standardfeed.h
+++ b/src/librssguard/services/standard/standardfeed.h
@@ -104,6 +104,9 @@ class StandardFeed : public Feed {
bool provide_input,
const QString& input = {});
+ QString lastEtag() const;
+ void setLastEtag(const QString& etag);
+
public slots:
void fetchMetadataForItself();
@@ -119,6 +122,7 @@ class StandardFeed : public Feed {
NetworkFactory::NetworkAuthentication m_protection = NetworkFactory::NetworkAuthentication::NoAuthentication;
QString m_username;
QString m_password;
+ QString m_lastEtag;
};
Q_DECLARE_METATYPE(StandardFeed::SourceType)
diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp
index ad64c4fe1..3695de269 100644
--- a/src/librssguard/services/standard/standardserviceroot.cpp
+++ b/src/librssguard/services/standard/standardserviceroot.cpp
@@ -48,6 +48,12 @@ StandardServiceRoot::~StandardServiceRoot() {
qDeleteAll(m_feedContextMenu);
}
+void StandardServiceRoot::onDatabaseCleanup() {
+ for (Feed* fd : getSubTreeFeeds()) {
+ qobject_cast(fd)->setLastEtag({});
+ }
+}
+
void StandardServiceRoot::start(bool freshly_activated) {
DatabaseQueries::loadRootFromDatabase(this);
@@ -175,6 +181,12 @@ QList StandardServiceRoot::obtainNewMessages(Feed* feed,
headers << NetworkFactory::generateBasicAuthHeader(f->protection(), f->username(), f->password());
+ if (!f->lastEtag().isEmpty()) {
+ headers.append({QSL("If-None-Match").toLocal8Bit(), f->lastEtag().toLocal8Bit()});
+
+ qDebugNN << "Using ETag value:" << QUOTE_W_SPACE_DOT(f->lastEtag());
+ }
+
auto network_result = NetworkFactory::performNetworkOperation(feed->source(),
download_timeout,
{},
@@ -186,14 +198,15 @@ QList StandardServiceRoot::obtainNewMessages(Feed* feed,
{},
networkProxy());
- // qDebugNN << "etag:" << network_result.m_headers["ETag"];
-
if (network_result.m_networkError != QNetworkReply::NetworkError::NoError) {
qWarningNN << LOGSEC_CORE << "Error" << QUOTE_W_SPACE(network_result.m_networkError)
<< "during fetching of new messages for feed" << QUOTE_W_SPACE_DOT(feed->source());
throw FeedFetchException(Feed::Status::NetworkError,
NetworkFactory::networkErrorText(network_result.m_networkError));
}
+ else {
+ f->setLastEtag(network_result.m_headers.value(QSL("ETag")));
+ }
}
else if (f->sourceType() == StandardFeed::SourceType::LocalFile) {
feed_contents = IOFactory::readFile(feed->source());
diff --git a/src/librssguard/services/standard/standardserviceroot.h b/src/librssguard/services/standard/standardserviceroot.h
index be9a8f2a6..95f2fc7bf 100644
--- a/src/librssguard/services/standard/standardserviceroot.h
+++ b/src/librssguard/services/standard/standardserviceroot.h
@@ -24,6 +24,7 @@ class StandardServiceRoot : public ServiceRoot {
explicit StandardServiceRoot(RootItem* parent = nullptr);
virtual ~StandardServiceRoot();
+ virtual void onDatabaseCleanup();
virtual void start(bool freshly_activated);
virtual void stop();
virtual QString code() const;