mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 12:31:52 +02:00
* Report last op's guid in DatabaseCommand_LoadOps' done signal.
This commit is contained in:
parent
395a1a58c2
commit
e462c3a3d9
@ -8,12 +8,12 @@ DatabaseCommand_loadOps::exec( DatabaseImpl* dbi )
|
||||
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
query.prepare( QString(
|
||||
"SELECT guid, command, json, compressed "
|
||||
"SELECT guid, command, json, compressed, singleton "
|
||||
"FROM oplog "
|
||||
"WHERE source %1 "
|
||||
"AND id > coalesce((SELECT id FROM oplog WHERE guid = ?),0) "
|
||||
"ORDER BY id ASC"
|
||||
).arg( source()->isLocal() ? "IS NULL" : QString("= %1").arg(source()->id()) )
|
||||
).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
|
||||
);
|
||||
query.addBindValue( m_since );
|
||||
if( !query.exec() )
|
||||
@ -21,6 +21,7 @@ DatabaseCommand_loadOps::exec( DatabaseImpl* dbi )
|
||||
Q_ASSERT(0);
|
||||
}
|
||||
|
||||
QString lastguid = m_since;
|
||||
while( query.next() )
|
||||
{
|
||||
dbop_ptr op( new DBOp );
|
||||
@ -28,10 +29,12 @@ DatabaseCommand_loadOps::exec( DatabaseImpl* dbi )
|
||||
op->command = query.value( 1 ).toString();
|
||||
op->payload = query.value( 2 ).toByteArray();
|
||||
op->compressed = query.value( 3 ).toBool();
|
||||
op->singleton = query.value( 4 ).toBool();
|
||||
|
||||
lastguid = op->guid;
|
||||
ops << op;
|
||||
}
|
||||
|
||||
qDebug() << "Loaded" << ops.length() << "ops from db";
|
||||
|
||||
emit done( m_since, ops );
|
||||
emit done( m_since, lastguid, ops );
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
virtual QString commandname() const { return "loadops"; }
|
||||
|
||||
signals:
|
||||
void done( QString lastguid, QList< dbop_ptr > ops );
|
||||
void done( QString sinceguid, QString lastguid, QList< dbop_ptr > ops );
|
||||
|
||||
private:
|
||||
QString m_since; // guid to load from
|
||||
|
@ -10,6 +10,7 @@ struct DBOp
|
||||
QString command;
|
||||
QByteArray payload;
|
||||
bool compressed;
|
||||
bool singleton;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<DBOp> dbop_ptr;
|
||||
|
@ -262,17 +262,18 @@ DBSyncConnection::sendOps()
|
||||
source_ptr src = SourceList::instance()->getLocal();
|
||||
|
||||
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, m_lastSentOp );
|
||||
connect( cmd, SIGNAL( done( QString, QList< dbop_ptr > ) ),
|
||||
this, SLOT( sendOpsData( QString, QList< dbop_ptr > ) ) );
|
||||
connect( cmd, SIGNAL( done( QString, QString, QList< dbop_ptr > ) ),
|
||||
this, SLOT( sendOpsData( QString, QString, QList< dbop_ptr > ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DBSyncConnection::sendOpsData( QString sinceguid, QList< dbop_ptr > ops )
|
||||
DBSyncConnection::sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ptr > ops )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << sinceguid << "Num ops to send: " << ops.length();
|
||||
qDebug() << Q_FUNC_INFO << sinceguid << lastguid << "Num ops to send:" << ops.length();
|
||||
m_lastSentOp = lastguid;
|
||||
|
||||
if( ops.length() == 0 )
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ private slots:
|
||||
void gotUs( const QVariantMap& m );
|
||||
void gotThemCache( const QVariantMap& m );
|
||||
void lastOpApplied();
|
||||
void sendOpsData( QString sinceguid, QList< dbop_ptr > ops );
|
||||
void sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ptr > ops );
|
||||
void check();
|
||||
void idleTimeout();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user