Skip to content

Commit

Permalink
Check if the changelog and id map tables exist before trying to delet…
Browse files Browse the repository at this point in the history
…e entries

from them. In case the tables do not exist, we consider the removal to have
succeeded.
  • Loading branch information
Santosh Puranik committed Apr 6, 2011
1 parent bafa892 commit 748cf5a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
libmeegosyncml (0.4.13) stable; urgency=low

* Check if tables exist before removing change logs and anchors.

-- Santosh Puranik <santosh.puranik@nokia.com> Wed, 06 Apr 2011 20:00:00 +0530

libmeegosyncml (0.4.12) stable; urgency=low

* Fixes: NB#223952 - Not all the contacts are syncd from DUT to S60
Expand Down
51 changes: 33 additions & 18 deletions src/ChangeLog.cpp
Expand Up @@ -356,21 +356,28 @@ bool ChangeLog::removeAnchors( QSqlDatabase& aDbHandle )

bool success = false;

const QString queryString( "DELETE FROM change_logs WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );
QStringList tables = aDbHandle.tables();

QSqlQuery query( queryString, aDbHandle );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );


if( query.exec() ) {
if( !tables.contains("change_logs") ) {
LOG_DEBUG("Change logs table not present. Considering anchors as removed");
success = true;
}
else {
LOG_WARNING( "Could not remove anchors:" << query.lastError() );
}
const QString queryString( "DELETE FROM change_logs WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );


if( query.exec() ) {
success = true;
}
else {
LOG_WARNING( "Could not remove anchors:" << query.lastError() );
}
}
return success;
}

Expand Down Expand Up @@ -464,18 +471,26 @@ bool ChangeLog::removeMaps( QSqlDatabase& aDbHandle )

bool success = false;

const QString queryString( "DELETE FROM id_maps WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );
QStringList tables = aDbHandle.tables();

QSqlQuery query( queryString, aDbHandle );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );

if( query.exec() ) {
if( !tables.contains("id_maps") ) {
LOG_DEBUG("id maps table not present");
success = true;
}
else {
LOG_WARNING( "Could not remove ID maps:" << query.lastError() );
const QString queryString( "DELETE FROM id_maps WHERE remote_device = :remote_device AND source_db_uri = :source_db_uri AND sync_direction = :sync_direction" );

QSqlQuery query( queryString, aDbHandle );
query.bindValue( ":remote_device", iRemoteDevice );
query.bindValue( ":source_db_uri", iSourceDbURI );
query.bindValue( ":sync_direction", iSyncDirection );

if( query.exec() ) {
success = true;
}
else {
LOG_WARNING( "Could not remove ID maps:" << query.lastError() );
}
}

return success;
Expand Down

0 comments on commit 748cf5a

Please sign in to comment.