mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Don't sync empty DbCmd_DeleteFiles & irrelevant DbCmd_LogPlaybacks.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -44,17 +44,18 @@ public:
|
|||||||
{
|
{
|
||||||
setSource( source );
|
setSource( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
|
explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
|
||||||
: DatabaseCommandLoggable( parent ), m_ids( ids )
|
: DatabaseCommandLoggable( parent ), m_ids( ids )
|
||||||
{
|
{
|
||||||
setSource( source );
|
setSource( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual QString commandname() const { return "deletefiles"; }
|
virtual QString commandname() const { return "deletefiles"; }
|
||||||
|
|
||||||
virtual void exec( DatabaseImpl* );
|
virtual void exec( DatabaseImpl* );
|
||||||
virtual bool doesMutates() const { return true; }
|
virtual bool doesMutates() const { return true; }
|
||||||
|
virtual bool localOnly() const { return m_files.isEmpty(); }
|
||||||
virtual void postCommitHook();
|
virtual void postCommitHook();
|
||||||
|
|
||||||
QStringList files() const { return m_files; }
|
QStringList files() const { return m_files; }
|
||||||
|
@@ -28,16 +28,10 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
// After changing a collection, we need to tell other bits of the system:
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_LogPlayback::postCommitHook()
|
DatabaseCommand_LogPlayback::postCommitHook()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
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 ) ),
|
connect( this, SIGNAL( trackPlaying( Tomahawk::query_ptr ) ),
|
||||||
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
source().data(), SLOT( onPlaybackStarted( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||||
@@ -56,12 +50,8 @@ DatabaseCommand_LogPlayback::postCommitHook()
|
|||||||
emit trackPlaying( q );
|
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();
|
Servent::instance()->triggerDBSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,3 +93,11 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
query.exec();
|
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> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
|
|
||||||
virtual bool doesMutates() const { return true; }
|
virtual bool doesMutates() const { return true; }
|
||||||
virtual bool singletonCmd() const { return ( m_action == Started ); }
|
virtual bool singletonCmd() const { return ( m_action == Started ); }
|
||||||
|
virtual bool localOnly() const;
|
||||||
|
|
||||||
QString artist() const { return m_artist; }
|
QString artist() const { return m_artist; }
|
||||||
void setArtist( const QString& s ) { m_artist = s; }
|
void setArtist( const QString& s ) { m_artist = s; }
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* 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
|
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
|
// We only save our own ops to the oplog, since incoming ops from peers
|
||||||
// are applied immediately.
|
// are applied immediately.
|
||||||
@@ -119,7 +119,7 @@ DatabaseWorker::doWork()
|
|||||||
// Crazy idea: if peers had keypairs and could sign ops/msgs, in theory it
|
// 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,
|
// 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.
|
// 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
|
// save to op-log
|
||||||
DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
|
DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
|
||||||
@@ -148,7 +148,7 @@ DatabaseWorker::doWork()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cmd->doesMutates() )
|
if ( cmd->doesMutates() )
|
||||||
{
|
{
|
||||||
qDebug() << "Committing" << cmd->commandname();;
|
qDebug() << "Committing" << cmd->commandname();;
|
||||||
if( !m_dbimpl->database().commit() )
|
if( !m_dbimpl->database().commit() )
|
||||||
|
Reference in New Issue
Block a user