Skip to content

Commit

Permalink
Merge pull request #15 from sailfishos/no_db_check
Browse files Browse the repository at this point in the history
[transfer-engine] Don't try opening database if its file doesn't exist. JB#47387
  • Loading branch information
pvuorela committed Apr 5, 2024
2 parents 25a9d2d + b523e8d commit 3b4ac08
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions declarative/declarativetransfermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TransferModel::Status TransferModel::status() const

void TransferModel::refresh()
{
if (!m_complete || m_roles.isEmpty()) {
if (!m_complete) {
return;
}

Expand Down Expand Up @@ -199,12 +199,12 @@ void TransferModel::componentComplete()
QDBusConnection::sessionBus(),
this);

connect(m_client, SIGNAL(progressChanged(int,double)),
this, SLOT(refresh()));
connect(m_client, SIGNAL(transfersChanged()),
this, SLOT(refresh()));
connect(m_client, SIGNAL(statusChanged(int,int)),
this, SLOT(refresh()));
connect(m_client, SIGNAL(progressChanged(int,double)),
this, SLOT(refresh()));
connect(m_client, SIGNAL(transfersChanged()),
this, SLOT(refresh()));
connect(m_client, SIGNAL(statusChanged(int,int)),
this, SLOT(refresh()));
}

void TransferModel::insertRange(
Expand Down Expand Up @@ -411,7 +411,12 @@ QSqlDatabase TransferModel::database()
+ DB_PATH + QDir::separator()
+ DB_NAME;

TransferDatabase database;
if (!QFile::exists(absDbPath)) {
qWarning() << "Database file doesn't exist:" << absDbPath;
return QSqlDatabase();
}

TransferDatabase database;
database.setDatabaseName(absDbPath);
database.setConnectOptions(QLatin1String("QSQLITE_OPEN_READONLY")); // sanity check
thread_database.setLocalData(database);
Expand Down

0 comments on commit 3b4ac08

Please sign in to comment.