1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-18 23:09:42 +01:00

* Added a --dumpdb command line option.

This commit is contained in:
Christian Muehlhaeuser 2012-01-19 18:10:57 +01:00
parent 36789637a2
commit 46723bf9d3

View File

@ -80,6 +80,32 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
m_fuzzyIndex = new FuzzyIndex( *this, schemaUpdated );
tDebug( LOGVERBOSE ) << "Loaded index:" << t.elapsed();
if ( qApp->arguments().contains( "--dumpdb" ) )
{
QFile dump( "dbdump.txt" );
if ( !dump.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
tDebug() << "Couldn't open dbdump.txt for writing!";
Q_ASSERT( false );
}
else
{
QTextStream dumpout( &dump );
query.exec( "SELECT * FROM oplog" );
while ( query.next() )
{
dumpout << "ID: " << query.value( 0 ).toInt() << endl
<< "GUID: " << query.value( 2 ).toString() << endl
<< "Command: " << query.value( 3 ).toString() << endl
<< "Singleton: " << query.value( 4 ).toBool() << endl
<< "JSON: " << ( query.value( 5 ).toBool() ? qUncompress( query.value( 6 ).toByteArray() ) : query.value( 6 ).toByteArray() )
<< endl << endl << endl;
}
}
::exit( 0 );
}
}