Commit e05cc3bd authored by Ahmad Samir's avatar Ahmad Samir Committed by Daniel Vrátil

Prevent crash by catching exceptions thrown by Xapian::WritableDatabase::commit

BUG: 418804
parent 25041b07
Pipeline #32511 passed with stage
in 29 minutes and 26 seconds
......@@ -27,10 +27,8 @@ AkonotesIndexer::AkonotesIndexer(const QString &path)
AkonotesIndexer::~AkonotesIndexer()
{
if (m_db) {
m_db->commit();
delete m_db;
}
commit();
delete m_db;
}
QStringList AkonotesIndexer::mimeTypes() const
......@@ -125,9 +123,16 @@ void AkonotesIndexer::processPart(KMime::Content *content, KMime::Content *mainC
void AkonotesIndexer::commit()
{
if (m_db) {
if (!m_db) {
return;
}
try {
m_db->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
void AkonotesIndexer::remove(const Akonadi::Item &item)
......
......@@ -30,10 +30,8 @@ CalendarIndexer::CalendarIndexer(const QString &path)
CalendarIndexer::~CalendarIndexer()
{
if (m_db) {
m_db->commit();
delete m_db;
}
commit();
delete m_db;
}
QStringList CalendarIndexer::mimeTypes() const
......@@ -59,9 +57,16 @@ void CalendarIndexer::index(const Akonadi::Item &item)
void CalendarIndexer::commit()
{
if (m_db) {
if (!m_db) {
return;
}
try {
m_db->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
void CalendarIndexer::remove(const Akonadi::Item &item)
......
......@@ -149,7 +149,14 @@ void CollectionIndexer::move(const Akonadi::Collection &collection, const Akonad
void CollectionIndexer::commit()
{
if (m_db) {
if (!m_db) {
return;
}
try {
m_db->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
......@@ -31,10 +31,8 @@ ContactIndexer::ContactIndexer(const QString &path)
ContactIndexer::~ContactIndexer()
{
if (m_db) {
m_db->commit();
delete m_db;
}
commit();
delete m_db;
}
QStringList ContactIndexer::mimeTypes() const
......@@ -162,9 +160,16 @@ void ContactIndexer::remove(const Akonadi::Collection &collection)
void ContactIndexer::commit()
{
if (m_db) {
if (!m_db) {
return;
}
try {
m_db->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
void ContactIndexer::move(Akonadi::Item::Id itemId, Akonadi::Collection::Id from, Akonadi::Collection::Id to)
......
......@@ -42,15 +42,9 @@ EmailIndexer::EmailIndexer(const QString &path, const QString &contactDbPath)
EmailIndexer::~EmailIndexer()
{
if (m_db) {
m_db->commit();
delete m_db;
}
if (m_contactDb) {
m_contactDb->commit();
delete m_contactDb;
}
commit();
delete m_db;
delete m_contactDb;
}
QStringList EmailIndexer::mimeTypes() const
......@@ -397,9 +391,20 @@ void EmailIndexer::move(Akonadi::Item::Id itemId, Akonadi::Collection::Id from,
void EmailIndexer::commit()
{
if (m_db) {
m_db->commit();
try {
m_db->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
if (m_contactDb) {
m_contactDb->commit();
try {
m_contactDb->commit();
} catch (const Xapian::Error &err) {
qCWarning(AKONADI_INDEXER_AGENT_LOG) << err.get_error_string();
}
qCDebug(AKONADI_INDEXER_AGENT_LOG) << "Xapian Committed";
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment