diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index bdda0209e..51ef5256f 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -26,7 +26,7 @@ https://github.com/sponsors/martinrotter - + none diff --git a/src/librssguard/database/databasequeries.cpp b/src/librssguard/database/databasequeries.cpp index 1b1182720..f348eb4d8 100644 --- a/src/librssguard/database/databasequeries.cpp +++ b/src/librssguard/database/databasequeries.cpp @@ -242,6 +242,7 @@ bool DatabaseQueries::createLabel(const QSqlDatabase& db, Label* label, int acco q.bindValue(QSL(":color"), label->color().name()); q.bindValue(QSL(":custom_id"), label->customId()); q.bindValue(QSL(":account_id"), account_id); + auto res = q.exec(); if (res && q.lastInsertId().isValid()) { @@ -1368,6 +1369,14 @@ QPair DatabaseQueries::updateMessages(QSqlDatabase db, << "Message" << QUOTE_W_SPACE(msg->m_customId) << "will not be inserted to DB because it does not meet DB constraints."; + + // Message is not inserted to DB at last, + // fix numbers. + if (!msg->m_isRead) { + updated_messages.first--; + } + + updated_messages.second--; continue; } @@ -1398,7 +1407,6 @@ QPair DatabaseQueries::updateMessages(QSqlDatabase db, if (bulk_error.isValid()) { QString txt = bulk_error.text() + bulk_error.databaseText() + bulk_error.driverText(); - //IOFactory::writeFile("aa.sql", final_bulk.toUtf8()); qCriticalNN << LOGSEC_DB << "Failed bulk insert of articles:" << QUOTE_W_SPACE_DOT(txt); @@ -1761,7 +1769,7 @@ bool DatabaseQueries::purgeLabelsAndLabelAssignments(const QSqlDatabase& db, int return succ; } -bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id) { +void DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id) { // Iterate all children. auto str = tree_root->getSubTree(); @@ -1779,14 +1787,10 @@ bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_ro for (RootItem* lbl : qAsConst(ch)) { Label* label = lbl->toLabel(); - if (!createLabel(db, label, account_id)) { - return false; - } + createLabel(db, label, account_id); } } } - - return true; } QStringList DatabaseQueries::customIdsOfMessagesFromAccount(const QSqlDatabase& db, int account_id, bool* ok) { diff --git a/src/librssguard/database/databasequeries.h b/src/librssguard/database/databasequeries.h index 375d95c83..de06513ae 100644 --- a/src/librssguard/database/databasequeries.h +++ b/src/librssguard/database/databasequeries.h @@ -121,7 +121,7 @@ class DatabaseQueries { static bool cleanImportantMessages(const QSqlDatabase& db, bool clean_read_only, int account_id); static bool cleanUnreadMessages(const QSqlDatabase& db, int account_id); static bool cleanFeeds(const QSqlDatabase& db, const QStringList& ids, bool clean_read_only, int account_id); - static bool storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id); + static void storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id); static void createOverwriteFeed(const QSqlDatabase& db, Feed* feed, int account_id, int parent_id); static void createOverwriteCategory(const QSqlDatabase& db, Category* category, int account_id, int parent_id); static bool deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id); diff --git a/src/librssguard/services/abstract/labelsnode.cpp b/src/librssguard/services/abstract/labelsnode.cpp index bf04bc12a..a6f610b80 100644 --- a/src/librssguard/services/abstract/labelsnode.cpp +++ b/src/librssguard/services/abstract/labelsnode.cpp @@ -4,6 +4,7 @@ #include "database/databasefactory.h" #include "database/databasequeries.h" +#include "exceptions/applicationexception.h" #include "gui/dialogs/formaddeditlabel.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" @@ -61,9 +62,14 @@ void LabelsNode::createLabel() { if (new_lbl != nullptr) { QSqlDatabase db = qApp->database()->driver()->connection(metaObject()->className()); - DatabaseQueries::createLabel(db, new_lbl, getParentServiceRoot()->accountId()); + try { + DatabaseQueries::createLabel(db, new_lbl, getParentServiceRoot()->accountId()); - getParentServiceRoot()->requestItemReassignment(new_lbl, this); + getParentServiceRoot()->requestItemReassignment(new_lbl, this); + } + catch (const ApplicationException& ex) { + new_lbl->deleteLater(); + } } } else {