This commit is contained in:
Martin Rotter 2023-10-24 08:35:37 +02:00
parent 2b4f910953
commit 3f0f26e28e
11 changed files with 50 additions and 12 deletions

View File

@ -7486,17 +7486,17 @@ Also, you can post-process generated feed data with yet another script if you wi
<translation>Error when loading initial feeds</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="301"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="308"/>
<source>Fetch metadata</source>
<translation>Fetch metadata</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="461"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="468"/>
<source>Export feeds</source>
<translation>Export feeds</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="462"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="469"/>
<source>Import feeds</source>
<translation>Import feeds</translation>
</message>
@ -7521,22 +7521,22 @@ Also, you can post-process generated feed data with yet another script if you wi
<translation>Cannot add feed because another critical operation is ongoing.</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="427"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="434"/>
<source>Cannot add category</source>
<translation>Cannot add category</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="428"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="435"/>
<source>Cannot add category because another critical operation is ongoing.</source>
<translation>Cannot add category because another critical operation is ongoing.</translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="415"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="422"/>
<source>Import was completely successful.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="412"/>
<location filename="../src/librssguard/services/standard/standardserviceroot.cpp" line="419"/>
<source>Some feeds/categories were not imported due to error, check debug log for more details.</source>
<translation type="unfinished"></translation>
</message>

View File

@ -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();

View File

@ -79,6 +79,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
RootItem* rootItem() const;
void setupFonts();
void informAboutDatabaseCleanup();
public slots:
void loadActivatedServiceAccounts();

View File

@ -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 {

View File

@ -479,6 +479,8 @@ UnreadNode* ServiceRoot::unreadNode() const {
return m_unreadNode;
}
void ServiceRoot::onDatabaseCleanup() {}
void ServiceRoot::syncIn() {
QIcon original_icon = icon();

View File

@ -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();

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -48,6 +48,12 @@ StandardServiceRoot::~StandardServiceRoot() {
qDeleteAll(m_feedContextMenu);
}
void StandardServiceRoot::onDatabaseCleanup() {
for (Feed* fd : getSubTreeFeeds()) {
qobject_cast<StandardFeed*>(fd)->setLastEtag({});
}
}
void StandardServiceRoot::start(bool freshly_activated) {
DatabaseQueries::loadRootFromDatabase<StandardCategory, StandardFeed>(this);
@ -175,6 +181,12 @@ QList<Message> 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<Message> 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());

View File

@ -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;