1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Debugging for delete files issue

This commit is contained in:
Jeff Mitchell
2011-10-10 10:35:28 -04:00
parent d37fd8955c
commit cfa2268c05
2 changed files with 14 additions and 2 deletions

View File

@@ -67,9 +67,10 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
if ( source()->isLocal() ) if ( source()->isLocal() )
{ {
tDebug() << Q_FUNC_INFO << " source is local";
if ( m_dir.path() != QString( "." ) ) if ( m_dir.path() != QString( "." ) )
{ {
qDebug() << "Deleting" << m_dir.path() << "from db for localsource" << srcid; tDebug() << "Deleting" << m_dir.path() << "from db for localsource" << srcid;
TomahawkSqlQuery dirquery = dbi->newquery(); TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND url LIKE ?" ) ); dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND url LIKE ?" ) );
@@ -82,7 +83,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
if ( fi.canonicalPath() != m_dir.canonicalPath() ) if ( fi.canonicalPath() != m_dir.canonicalPath() )
{ {
if ( lastPath != fi.canonicalPath() ) if ( lastPath != fi.canonicalPath() )
qDebug() << "Skipping subdir:" << fi.canonicalPath(); tDebug() << "Skipping subdir:" << fi.canonicalPath();
lastPath = fi.canonicalPath(); lastPath = fi.canonicalPath();
continue; continue;
@@ -94,6 +95,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
} }
else if ( !m_ids.isEmpty() ) else if ( !m_ids.isEmpty() )
{ {
tDebug() << Q_FUNC_INFO << " deleting given ids";
TomahawkSqlQuery dirquery = dbi->newquery(); TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND id IN ( ? )" ) ); dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND id IN ( ? )" ) );
@@ -107,6 +109,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
dirquery.exec(); dirquery.exec();
while ( dirquery.next() ) while ( dirquery.next() )
m_files << dirquery.value( 1 ).toString(); m_files << dirquery.value( 1 ).toString();
tDebug() << Q_FUNC_INFO << " files selected for delete: " << m_files;
} }
else if ( m_deleteAll ) else if ( m_deleteAll )
{ {
@@ -154,6 +158,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
} }
else if ( !m_ids.isEmpty() ) else if ( !m_ids.isEmpty() )
{ {
tDebug() << Q_FUNC_INFO << " executing delete of ids " << m_ids;
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( ? )" ) delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( ? )" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) .arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
.arg( source()->isLocal() ? "id" : "url" ) ); .arg( source()->isLocal() ? "id" : "url" ) );
@@ -171,6 +176,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
<< delquery.lastError().driverText() << delquery.lastError().driverText()
<< delquery.boundValues(); << delquery.boundValues();
} }
tDebug() << Q_FUNC_INFO << " executed query was: " << delquery.lastQuery();
} }
emit done( m_files, source()->collection() ); emit done( m_files, source()->collection() );

View File

@@ -28,6 +28,8 @@
#include "dllmacro.h" #include "dllmacro.h"
#include "utils/logger.h"
class DLLEXPORT DatabaseCommand_DeleteFiles : public DatabaseCommandLoggable class DLLEXPORT DatabaseCommand_DeleteFiles : public DatabaseCommandLoggable
{ {
Q_OBJECT Q_OBJECT
@@ -42,18 +44,21 @@ public:
explicit DatabaseCommand_DeleteFiles( const Tomahawk::source_ptr& source, QObject* parent = 0 ) explicit DatabaseCommand_DeleteFiles( const Tomahawk::source_ptr& source, QObject* parent = 0 )
: DatabaseCommandLoggable( parent ), m_deleteAll( true ) : DatabaseCommandLoggable( parent ), m_deleteAll( true )
{ {
tDebug() << Q_FUNC_INFO << " deleting single source";
setSource( source ); setSource( source );
} }
explicit DatabaseCommand_DeleteFiles( const QDir& dir, const Tomahawk::source_ptr& source, QObject* parent = 0 ) explicit DatabaseCommand_DeleteFiles( const QDir& dir, const Tomahawk::source_ptr& source, QObject* parent = 0 )
: DatabaseCommandLoggable( parent ), m_dir( dir ), m_deleteAll( false ) : DatabaseCommandLoggable( parent ), m_dir( dir ), m_deleteAll( false )
{ {
tDebug() << Q_FUNC_INFO << " deleting dir " << dir;
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 ), m_deleteAll( false ) : DatabaseCommandLoggable( parent ), m_ids( ids ), m_deleteAll( false )
{ {
tDebug() << Q_FUNC_INFO << " deleting ids " << ids << " with size " << ids.count();
setSource( source ); setSource( source );
} }