mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
* Don't reset lastop for singleton commands.
This commit is contained in:
@@ -90,15 +90,20 @@ DatabaseWorker::doWork( QSharedPointer<DatabaseCommand> cmd )
|
|||||||
// Make a note of the last guid we applied for this source
|
// Make a note of the last guid we applied for this source
|
||||||
// so we can always request just the newer ops in future.
|
// so we can always request just the newer ops in future.
|
||||||
//
|
//
|
||||||
qDebug() << "Setting lastop for source" << cmd->source()->id() << "to" << cmd->guid();
|
if ( !cmd->singletonCmd() )
|
||||||
TomahawkSqlQuery query = m_dbimpl->newquery();
|
|
||||||
query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
|
|
||||||
query.addBindValue( cmd->guid() );
|
|
||||||
query.addBindValue( cmd->source()->id() );
|
|
||||||
if( !query.exec() )
|
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to set lastop";
|
qDebug() << "Setting lastop for source" << cmd->source()->id() << "to" << cmd->guid();
|
||||||
throw "Failed to set lastop";
|
|
||||||
|
TomahawkSqlQuery query = m_dbimpl->newquery();
|
||||||
|
query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
|
||||||
|
query.addBindValue( cmd->guid() );
|
||||||
|
query.addBindValue( cmd->source()->id() );
|
||||||
|
|
||||||
|
if( !query.exec() )
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to set lastop";
|
||||||
|
throw "Failed to set lastop";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,12 +161,8 @@ void
|
|||||||
DatabaseWorker::logOp( DatabaseCommandLoggable* command )
|
DatabaseWorker::logOp( DatabaseCommandLoggable* command )
|
||||||
{
|
{
|
||||||
TomahawkSqlQuery oplogquery = m_dbimpl->newquery();
|
TomahawkSqlQuery oplogquery = m_dbimpl->newquery();
|
||||||
TomahawkSqlQuery oplogdelquery = m_dbimpl->newquery();
|
|
||||||
|
|
||||||
oplogquery.prepare( "INSERT INTO oplog(source, guid, command, singleton, compressed, json) "
|
oplogquery.prepare( "INSERT INTO oplog(source, guid, command, singleton, compressed, json) "
|
||||||
"VALUES(?, ?, ?, ?, ?, ?)" );
|
"VALUES(?, ?, ?, ?, ?, ?)" );
|
||||||
oplogdelquery.prepare( QString( "DELETE FROM oplog WHERE source %1 AND singleton = 'true' AND command = ?" )
|
|
||||||
.arg( command->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( command->source()->id() ) ) );
|
|
||||||
|
|
||||||
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant( command );
|
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant( command );
|
||||||
QByteArray ba = m_serializer.serialize( variant );
|
QByteArray ba = m_serializer.serialize( variant );
|
||||||
@@ -183,6 +184,11 @@ DatabaseWorker::logOp( DatabaseCommandLoggable* command )
|
|||||||
if ( command->singletonCmd() )
|
if ( command->singletonCmd() )
|
||||||
{
|
{
|
||||||
qDebug() << "Singleton command, deleting previous oplog commands";
|
qDebug() << "Singleton command, deleting previous oplog commands";
|
||||||
|
|
||||||
|
TomahawkSqlQuery oplogdelquery = m_dbimpl->newquery();
|
||||||
|
oplogdelquery.prepare( QString( "DELETE FROM oplog WHERE source %1 AND singleton = 'true' AND command = ?" )
|
||||||
|
.arg( command->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( command->source()->id() ) ) );
|
||||||
|
|
||||||
oplogdelquery.bindValue( 0, command->commandname() );
|
oplogdelquery.bindValue( 0, command->commandname() );
|
||||||
oplogdelquery.exec();
|
oplogdelquery.exec();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user