mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Add an optimization to deletefiles
This commit is contained in:
@@ -119,11 +119,14 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
TomahawkSqlQuery dirquery = dbi->newquery();
|
||||
|
||||
dirquery.prepare( QString( "SELECT url FROM file WHERE source IS NULL" ) );
|
||||
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL" ) );
|
||||
|
||||
dirquery.exec();
|
||||
while ( dirquery.next() )
|
||||
m_files << dirquery.value( 0 ).toString();
|
||||
{
|
||||
m_ids << dirquery.value( 0 ).toString();
|
||||
m_files << dirquery.value( 1 ).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -144,6 +147,8 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
}
|
||||
|
||||
if ( m_deleteAll )
|
||||
{
|
||||
if ( !m_ids.isEmpty() )
|
||||
{
|
||||
delquery.prepare( QString( "DELETE FROM file WHERE source %1" )
|
||||
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) );
|
||||
@@ -155,9 +160,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
|
||||
<< delquery.lastError().driverText()
|
||||
<< delquery.boundValues();
|
||||
}
|
||||
|
||||
emit done( m_files, source()->collection() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ( !m_ids.isEmpty() )
|
||||
{
|
||||
|
Reference in New Issue
Block a user