Commit e60e89cd authored by Maik Qualmann's avatar Maik Qualmann

fix logic for stop processing in the for loop

CCBUGS: 383204
parent da911b5d
Pipeline #26515 failed with stage
in 60 minutes
......@@ -115,7 +115,9 @@ void CoreDbCopyManager::copyDatabases(const DbEngineParameters& fromDBParameters
DbEngineAction action = toDBbackend.getDBAction(QString::fromUtf8("Migrate_Cleanup_Prepare"));
BdEngineBackend::QueryState queryStateResult = toDBbackend.execDBAction(action);
// Accept SQL error because the foreign key may not exist.
if (queryStateResult == BdEngineBackend::ConnectionError)
{
emit finished(CoreDbCopyManager::failed, i18n("Error while preparing the target database."));
......@@ -123,10 +125,11 @@ void CoreDbCopyManager::copyDatabases(const DbEngineParameters& fromDBParameters
// Delete all tables
for (int i = (tablesSize - 1); m_isStopProcessing || i >= 0; --i)
for (int i = (tablesSize - 1) ; !m_isStopProcessing && (i >= 0) ; --i)
{
if ( m_isStopProcessing ||
toDBbackend.execDirectSql(QString::fromUtf8("DROP TABLE IF EXISTS %1;").arg(tables[i])) != BdEngineBackend::NoErrors)
if (m_isStopProcessing ||
(toDBbackend.execDirectSql(QString::fromUtf8("DROP TABLE IF EXISTS %1;").arg(tables[i])) != BdEngineBackend::NoErrors)
)
{
emit finished(CoreDbCopyManager::failed, i18n("Error while scrubbing the target database."));
fromDBbackend.close();
......@@ -137,12 +140,12 @@ void CoreDbCopyManager::copyDatabases(const DbEngineParameters& fromDBParameters
// Then create the schema
CoreDB albumDB(&toDBbackend);
CoreDB albumDB(&toDBbackend);
CoreDbSchemaUpdater updater(&albumDB, &toDBbackend, toDBParameters);
emit stepStarted(i18n("Create Schema..."));
if (!updater.update())
if (m_isStopProcessing || !updater.update())
{
emit finished(CoreDbCopyManager::failed, i18n("Error while creating the database schema."));
fromDBbackend.close();
......@@ -152,7 +155,7 @@ void CoreDbCopyManager::copyDatabases(const DbEngineParameters& fromDBParameters
// loop copying the tables, stop if an error is met
for (int i = 0; m_isStopProcessing || i < tablesSize; ++i)
for (int i = 0 ; !m_isStopProcessing && (i < tablesSize) ; ++i)
{
if (i < tablesSize)
{
......@@ -161,9 +164,9 @@ void CoreDbCopyManager::copyDatabases(const DbEngineParameters& fromDBParameters
// Now perform the copy action
if ( m_isStopProcessing ||
!copyTable(fromDBbackend, QString::fromUtf8("Migrate_Read_%1").arg(tables[i]),
toDBbackend, QString::fromUtf8("Migrate_Write_%1").arg(tables[i]))
if (m_isStopProcessing ||
!copyTable(fromDBbackend, QString::fromUtf8("Migrate_Read_%1").arg(tables[i]),
toDBbackend, QString::fromUtf8("Migrate_Write_%1").arg(tables[i]))
)
{
handleClosing(m_isStopProcessing, fromDBbackend, toDBbackend);
......@@ -232,7 +235,7 @@ bool CoreDbCopyManager::copyTable(CoreDbBackend& fromDBbackend,
int columnCount = result.record().count();
for (int i = 0; i < columnCount; ++i)
for (int i = 0 ; i < columnCount ; ++i)
{
//qCDebug(DIGIKAM_COREDB_LOG) << "Column: ["<< result.record().fieldName(i) << "]";
columnNames.append(result.record().fieldName(i));
......@@ -246,7 +249,7 @@ bool CoreDbCopyManager::copyTable(CoreDbBackend& fromDBbackend,
<< "] isActive [" << result.isActive()
<< "] result size: [" << result.size() << "]";
if (m_isStopProcessing == true)
if (m_isStopProcessing)
{
return false;
}
......
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