mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Keep an internal last op guid for DbSyncConnection.
This commit is contained in:
@@ -173,7 +173,7 @@ DatabaseImpl::file( int fid )
|
|||||||
m["bitrate"] = query.value( 6 ).toInt();
|
m["bitrate"] = query.value( 6 ).toInt();
|
||||||
m["artistid"] = query.value( 7 ).toInt();
|
m["artistid"] = query.value( 7 ).toInt();
|
||||||
m["albumid"] = query.value( 8 ).toInt();
|
m["albumid"] = query.value( 8 ).toInt();
|
||||||
m["trackid"] = query.value( 8 ).toInt();
|
m["trackid"] = query.value( 9 ).toInt();
|
||||||
m["artist"] = query.value( 10 ).toString();
|
m["artist"] = query.value( 10 ).toString();
|
||||||
m["album"] = query.value( 11 ).toString();
|
m["album"] = query.value( 11 ).toString();
|
||||||
m["track"] = query.value( 12 ).toString();
|
m["track"] = query.value( 12 ).toString();
|
||||||
|
@@ -14,13 +14,12 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "source.h"
|
|
||||||
|
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecommand.h"
|
#include "database/databasecommand.h"
|
||||||
#include "database/databasecommand_collectionstats.h"
|
#include "database/databasecommand_collectionstats.h"
|
||||||
#include "database/databasecommand_loadops.h"
|
#include "database/databasecommand_loadops.h"
|
||||||
#include "remotecollection.h"
|
#include "remotecollection.h"
|
||||||
|
#include "source.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
|
|
||||||
// close the dbsync connection after this much inactivity.
|
// close the dbsync connection after this much inactivity.
|
||||||
@@ -60,7 +59,7 @@ void
|
|||||||
DBSyncConnection::idleTimeout()
|
DBSyncConnection::idleTimeout()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "*************";
|
qDebug() << Q_FUNC_INFO << "*************";
|
||||||
shutdown(true);
|
shutdown( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,11 +154,13 @@ void
|
|||||||
DBSyncConnection::gotThemCache( const QVariantMap& m )
|
DBSyncConnection::gotThemCache( const QVariantMap& m )
|
||||||
{
|
{
|
||||||
m_themcache = m;
|
m_themcache = m;
|
||||||
qDebug() << "Sending a FETCHOPS cmd since:" << m.value("lastop").toString();
|
|
||||||
changeState(FETCHING);
|
changeState(FETCHING);
|
||||||
|
|
||||||
|
qDebug() << "Sending a FETCHOPS cmd since:" << m_themcache.value( "lastop" ).toString();
|
||||||
|
|
||||||
QVariantMap msg;
|
QVariantMap msg;
|
||||||
msg.insert( "method", "fetchops" );
|
msg.insert( "method", "fetchops" );
|
||||||
msg.insert( "lastop", m_themcache.value("lastop").toString() );
|
msg.insert( "lastop", m_themcache.value( "lastop" ).toString() );
|
||||||
sendMsg( msg );
|
sendMsg( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,9 +191,6 @@ DBSyncConnection::handleMsg( msg_ptr msg )
|
|||||||
Q_ASSERT( msg->is( Msg::JSON ) );
|
Q_ASSERT( msg->is( Msg::JSON ) );
|
||||||
|
|
||||||
QVariantMap m = msg->json().toMap();
|
QVariantMap m = msg->json().toMap();
|
||||||
|
|
||||||
//qDebug() << ">>>>" << m;
|
|
||||||
|
|
||||||
if( m.empty() )
|
if( m.empty() )
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to parse msg in dbsync";
|
qDebug() << "Failed to parse msg in dbsync";
|
||||||
@@ -256,13 +254,14 @@ DBSyncConnection::sendOps()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
const QString sinceguid = m_uscache.value( "lastop" ).toString();
|
if ( m_lastSentOp.isEmpty() )
|
||||||
|
m_lastSentOp = m_uscache.value( "lastop" ).toString();
|
||||||
|
|
||||||
qDebug() << "Will send peer all ops since" << sinceguid;
|
qDebug() << "Will send peer all ops since" << m_lastSentOp;
|
||||||
|
|
||||||
source_ptr src = SourceList::instance()->getLocal();
|
source_ptr src = SourceList::instance()->getLocal();
|
||||||
|
|
||||||
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, sinceguid );
|
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, m_lastSentOp );
|
||||||
connect( cmd, SIGNAL( done( QString, QList< dbop_ptr > ) ),
|
connect( cmd, SIGNAL( done( QString, QList< dbop_ptr > ) ),
|
||||||
this, SLOT( sendOpsData( QString, QList< dbop_ptr > ) ) );
|
this, SLOT( sendOpsData( QString, QList< dbop_ptr > ) ) );
|
||||||
|
|
||||||
|
@@ -60,6 +60,8 @@ private:
|
|||||||
QVariantMap m_us, m_uscache, m_themcache;
|
QVariantMap m_us, m_uscache, m_themcache;
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
|
QString m_lastSentOp;
|
||||||
|
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user