mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Work around QtSql bind bug to properly populate delete files for notifications to collections
This commit is contained in:
@@ -72,9 +72,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
|||||||
{
|
{
|
||||||
tDebug() << "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();
|
||||||
|
QString path( "file://" + m_dir.canonicalPath() + "/%" );
|
||||||
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 %1" ).arg( path ) );
|
||||||
dirquery.bindValue( 0, "file://" + m_dir.canonicalPath() + "/%" );
|
|
||||||
dirquery.exec();
|
dirquery.exec();
|
||||||
|
|
||||||
while ( dirquery.next() )
|
while ( dirquery.next() )
|
||||||
@@ -98,15 +97,13 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
|||||||
tDebug() << Q_FUNC_INFO << " deleting given ids";
|
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 ( ? )" ) );
|
|
||||||
|
|
||||||
QString idstring;
|
QString idstring;
|
||||||
foreach( const QVariant& id, m_ids )
|
foreach( const QVariant& id, m_ids )
|
||||||
idstring.append( id.toString() + ", " );
|
idstring.append( id.toString() + ", " );
|
||||||
idstring.chop( 2 ); //remove the trailing ", "
|
idstring.chop( 2 ); //remove the trailing ", "
|
||||||
|
|
||||||
|
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND id IN ( %1 )" ).arg( idstring ) );
|
||||||
|
|
||||||
dirquery.bindValue( 0, idstring );
|
|
||||||
tDebug() << Q_FUNC_INFO << " binding id string: " << idstring;
|
|
||||||
dirquery.exec();
|
dirquery.exec();
|
||||||
tDebug() << Q_FUNC_INFO << " result size: " << dirquery.size();
|
tDebug() << Q_FUNC_INFO << " result size: " << dirquery.size();
|
||||||
while ( dirquery.next() )
|
while ( dirquery.next() )
|
||||||
@@ -115,7 +112,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
|||||||
m_files << dirquery.value( 1 ).toString();
|
m_files << dirquery.value( 1 ).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << " executed query was: " << dirquery.executedQuery() << ", bound value is: " << dirquery.boundValue( 0 ).toString();
|
tDebug() << Q_FUNC_INFO << " executed query was: " << dirquery.executedQuery();
|
||||||
tDebug() << Q_FUNC_INFO << " files selected for delete: " << m_files;
|
tDebug() << Q_FUNC_INFO << " files selected for delete: " << m_files;
|
||||||
}
|
}
|
||||||
else if ( m_deleteAll )
|
else if ( m_deleteAll )
|
||||||
@@ -174,8 +171,11 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
|||||||
idstring.append( id.toString() + ", " );
|
idstring.append( id.toString() + ", " );
|
||||||
idstring.chop( 2 ); //remove the trailing ", "
|
idstring.chop( 2 ); //remove the trailing ", "
|
||||||
|
|
||||||
delquery.bindValue( 0, idstring );
|
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( %3 )" )
|
||||||
tDebug() << Q_FUNC_INFO << " bound idstring: " << idstring;
|
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
|
||||||
|
.arg( source()->isLocal() ? "id" : "url" )
|
||||||
|
.arg( idstring ) );
|
||||||
|
|
||||||
if( !delquery.exec() )
|
if( !delquery.exec() )
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to delete file:"
|
qDebug() << "Failed to delete file:"
|
||||||
@@ -184,7 +184,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
|||||||
<< delquery.boundValues();
|
<< delquery.boundValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << " executed query was: " << delquery.executedQuery() << ", bound value is: " << delquery.boundValue( 0 ).toString();
|
tDebug() << Q_FUNC_INFO << " executed query was: " << delquery.executedQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit done( m_files, source()->collection() );
|
emit done( m_files, source()->collection() );
|
||||||
|
Reference in New Issue
Block a user