mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
* Don't sync empty DbCmd_DeleteFiles & irrelevant DbCmd_LogPlaybacks.
This commit is contained in:
parent
caa8878b25
commit
b2c9028b54
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -44,17 +44,18 @@ public:
|
||||
{
|
||||
setSource( source );
|
||||
}
|
||||
|
||||
|
||||
explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent ), m_ids( ids )
|
||||
{
|
||||
setSource( source );
|
||||
}
|
||||
|
||||
|
||||
virtual QString commandname() const { return "deletefiles"; }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -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; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -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() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user