diff --git a/src/libtomahawk/network/dbsyncconnection.cpp b/src/libtomahawk/network/dbsyncconnection.cpp index 803d09501..3cd1694f3 100644 --- a/src/libtomahawk/network/dbsyncconnection.cpp +++ b/src/libtomahawk/network/dbsyncconnection.cpp @@ -133,6 +133,7 @@ DBSyncConnection::check() return; } + Q_ASSERT( m_cmds.isEmpty() ); m_uscache.clear(); m_us.clear(); @@ -143,10 +144,16 @@ DBSyncConnection::check() connect( cmd_us, SIGNAL( done( QVariantMap ) ), SLOT( gotUs( QVariantMap ) ) ); Database::instance()->enqueue( QSharedPointer(cmd_us) ); - Q_ASSERT( m_cmds.isEmpty() ); - DatabaseCommand_CollectionStats* cmd_them = new DatabaseCommand_CollectionStats( m_source ); - connect( cmd_them, SIGNAL( done( QVariantMap ) ), SLOT( gotThem( QVariantMap ) ) ); - Database::instance()->enqueue( QSharedPointer(cmd_them) ); + if ( m_source->lastCmdGuid().isEmpty() ) + { + DatabaseCommand_CollectionStats* cmd_them = new DatabaseCommand_CollectionStats( m_source ); + connect( cmd_them, SIGNAL( done( QVariantMap ) ), SLOT( gotThem( QVariantMap ) ) ); + Database::instance()->enqueue( QSharedPointer(cmd_them) ); + } + else + { + fetchOpsData( m_source->lastCmdGuid() ); + } // restarts idle countdown m_timer.start(); @@ -267,6 +274,9 @@ DBSyncConnection::executeCommands() if ( !m_cmds.isEmpty() ) { QSharedPointer cmd = m_cmds.takeFirst(); + if ( !cmd->singletonCmd() ) + m_source->setLastCmdGuid( cmd->guid() ); + connect( cmd.data(), SIGNAL( finished() ), SLOT( executeCommands() ) ); Database::instance()->enqueue( cmd ); } diff --git a/src/libtomahawk/source.cpp b/src/libtomahawk/source.cpp index d809389b4..f5c88549c 100644 --- a/src/libtomahawk/source.cpp +++ b/src/libtomahawk/source.cpp @@ -45,8 +45,6 @@ Source::Source( int id, const QString& username ) , m_avatar( 0 ) , m_fancyAvatar( 0 ) { - qDebug() << Q_FUNC_INFO << id << username; - m_scrubFriendlyName = qApp->arguments().contains( "--demo" ); if ( id == 0 ) diff --git a/src/libtomahawk/source.h b/src/libtomahawk/source.h index 36eeaee03..7efe154bd 100644 --- a/src/libtomahawk/source.h +++ b/src/libtomahawk/source.h @@ -102,6 +102,8 @@ public slots: private slots: void dbLoaded( unsigned int id, const QString& fname ); + QString lastCmdGuid() const { return m_lastCmdGuid; } + void setLastCmdGuid( const QString& guid ) { m_lastCmdGuid = guid; } void setOffline(); void setOnline(); @@ -114,12 +116,15 @@ private slots: private: void reportSocialAttributesChanged(); - bool m_isLocal; - bool m_online; - QString m_username, m_friendlyname; - int m_id; QList< QSharedPointer > m_collections; QVariantMap m_stats; + QString m_lastCmdGuid; + + bool m_isLocal; + bool m_online; + QString m_username; + QString m_friendlyname; + int m_id; bool m_scrubFriendlyName; Tomahawk::query_ptr m_currentTrack;