mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Don't sync empty DbCmd_DeleteFiles & irrelevant DbCmd_LogPlaybacks.
This commit is contained in:
@@ -55,6 +55,7 @@ public:
|
||||
|
||||
virtual void exec( DatabaseImpl* );
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool localOnly() const { return m_files.isEmpty(); }
|
||||
virtual void postCommitHook();
|
||||
|
||||
QStringList files() const { return m_files; }
|
||||
|
@@ -28,16 +28,10 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
// After changing a collection, we need to tell other bits of the system:
|
||||
void
|
||||
DatabaseCommand_LogPlayback::postCommitHook()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( source().isNull() || source()->collection().isNull() )
|
||||
{
|
||||
qDebug() << "Source has gone offline, not emitting to GUI.";
|
||||
return;
|
||||
}
|
||||
|
||||
connect( this, SIGNAL( trackPlaying( Tomahawk::query_ptr ) ),
|
||||
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||
@@ -56,12 +50,8 @@ DatabaseCommand_LogPlayback::postCommitHook()
|
||||
emit trackPlaying( q );
|
||||
}
|
||||
|
||||
if( source()->isLocal() )
|
||||
if ( source()->isLocal() )
|
||||
{
|
||||
// Only tell remote sources about tracks that we listen to long enough
|
||||
if ( m_secsPlayed < 20 )
|
||||
return;
|
||||
|
||||
Servent::instance()->triggerDBSync();
|
||||
}
|
||||
}
|
||||
@@ -103,3 +93,11 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
|
||||
|
||||
query.exec();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DatabaseCommand_LogPlayback::localOnly() const
|
||||
{
|
||||
return m_secsPlayed < 20;
|
||||
}
|
||||
|
||||
|
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool singletonCmd() const { return ( m_action == Started ); }
|
||||
virtual bool localOnly() const;
|
||||
|
||||
QString artist() const { return m_artist; }
|
||||
void setArtist( const QString& s ) { m_artist = s; }
|
||||
|
@@ -111,7 +111,7 @@ DatabaseWorker::doWork()
|
||||
{
|
||||
cmd->_exec( m_dbimpl ); // runs actual SQL stuff
|
||||
|
||||
if( cmd->loggable() && !cmd->localOnly() )
|
||||
if ( cmd->loggable() && !cmd->localOnly() )
|
||||
{
|
||||
// We only save our own ops to the oplog, since incoming ops from peers
|
||||
// are applied immediately.
|
||||
@@ -119,7 +119,7 @@ DatabaseWorker::doWork()
|
||||
// Crazy idea: if peers had keypairs and could sign ops/msgs, in theory it
|
||||
// would be safe to sync ops for friend A from friend B's cache, if he saved them,
|
||||
// which would mean you could get updates even if a peer was offline.
|
||||
if( cmd->source()->isLocal() )
|
||||
if ( cmd->source()->isLocal() )
|
||||
{
|
||||
// save to op-log
|
||||
DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
|
||||
@@ -148,7 +148,7 @@ DatabaseWorker::doWork()
|
||||
}
|
||||
}
|
||||
|
||||
if( cmd->doesMutates() )
|
||||
if ( cmd->doesMutates() )
|
||||
{
|
||||
qDebug() << "Committing" << cmd->commandname();;
|
||||
if( !m_dbimpl->database().commit() )
|
||||
|
Reference in New Issue
Block a user