From 42ea21ec794c381558738e7eb87bae309d3a376e Mon Sep 17 00:00:00 2001 From: christian linke Date: Tue, 2 Oct 2012 12:41:06 +0200 Subject: * [GAM-100] nonexisting tables are dropped Signed-off-by: christian linke --- AudioManagerDaemon/src/CAmDatabaseHandler.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/AudioManagerDaemon/src/CAmDatabaseHandler.cpp b/AudioManagerDaemon/src/CAmDatabaseHandler.cpp index e4e0bff..2110780 100644 --- a/AudioManagerDaemon/src/CAmDatabaseHandler.cpp +++ b/AudioManagerDaemon/src/CAmDatabaseHandler.cpp @@ -1248,16 +1248,19 @@ am_Error_e CAmDatabaseHandler::removeSinkDB(const am_sinkID_t sinkID) std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID); std::string command1 = "DROP table SinkConnectionFormat" + i2s(sinkID); - std::string command2 = "DROP table SinkMainSoundProperty" + i2s(sinkID); - std::string command3 = "DROP table SinkSoundProperty" + i2s(sinkID); + std::string command2 = "DROP table SinkSoundProperty" + i2s(sinkID); + std::string command3 = "DROP table SinkMainSoundProperty" + i2s(sinkID); if (!sqQuery(command)) return (E_DATABASE_ERROR); if (!sqQuery(command1)) return (E_DATABASE_ERROR); if (!sqQuery(command2)) return (E_DATABASE_ERROR); - if (!sqQuery(command3)) - return (E_DATABASE_ERROR); + if (visible) //only drop table if it ever existed + { + if (!sqQuery(command3)) + return (E_DATABASE_ERROR); + } logInfo("DatabaseHandler::removeSinkDB removed:", sinkID); if (mpDatabaseObserver != NULL) @@ -1287,8 +1290,12 @@ am_Error_e CAmDatabaseHandler::removeSourceDB(const am_sourceID_t sourceID) return (E_DATABASE_ERROR); if (!sqQuery(command2)) return (E_DATABASE_ERROR); - if (!sqQuery(command3)) - return (E_DATABASE_ERROR); + + if(visible) + { + if (!sqQuery(command3)) + return (E_DATABASE_ERROR); + } logInfo("DatabaseHandler::removeSourceDB removed:", sourceID); if (mpDatabaseObserver) mpDatabaseObserver->removedSource(sourceID, visible); -- cgit v1.2.1