diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp index 22d6f0fb1..602471c61 100644 --- a/src/libtomahawk/database/databaseimpl.cpp +++ b/src/libtomahawk/database/databaseimpl.cpp @@ -83,27 +83,7 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent ) 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; - } - } - + dumpDatabase(); ::exit( 0 ); } } @@ -115,6 +95,34 @@ DatabaseImpl::~DatabaseImpl() } +void +DatabaseImpl::dumpDatabase() +{ + 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 ); + TomahawkSqlQuery query = newquery(); + + 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; + } + } +} + + void DatabaseImpl::loadIndex() { diff --git a/src/libtomahawk/database/databaseimpl.h b/src/libtomahawk/database/databaseimpl.h index 0cd6b9498..0b6c9e963 100644 --- a/src/libtomahawk/database/databaseimpl.h +++ b/src/libtomahawk/database/databaseimpl.h @@ -84,6 +84,7 @@ public slots: private: QString cleanSql( const QString& sql ); bool updateSchema( int oldVersion ); + void dumpDatabase(); bool m_ready; QSqlDatabase m_db;