Commit e66883e9 authored by Matěj Laitl's avatar Matěj Laitl
Browse files

SqlRegistry: delete orphaned entries from the urls table, too

...in addition to removing other orphaned items. It sometimes happened
that an url entry with non-existent directory remained in the db, which
prevented SqlScanResultProcessor from cleaning it up properly.

BUGFIXES:
 * Fix a problem where ghost tracks would remain in the Local Collection
   until the database is wiped.

BUG: 319084
FIXED-IN: 2.8
parent f468ee06
......@@ -70,6 +70,8 @@ VERSION 2.8-Beta 1
not to fool users.
BUGFIXES:
* Fix a problem where ghost tracks would remain in the Local Collection until the
database is wiped. (BR 319084)
* Added missing CMake check for QtWebKit. (BR 321598)
* Definitely fix a bug where Local Collection wouldn't update in browser. (BR 262504)
* Fix crashed caused by race conditions at the end of the track scanning. (BR 319835)
......
......@@ -987,6 +987,14 @@ DatabaseUpdater::deleteAllRedundant( const QString &type )
arg( tablename, type ) );
}
void
DatabaseUpdater::deleteOrphanedByDirectory( const QString &table )
{
SqlStorage *storage = m_collection->sqlStorage();
QString query( "DELETE FROM %1 WHERE directory NOT IN ( SELECT id FROM directories )" );
storage->query( query.arg( table ) );
}
void
DatabaseUpdater::deleteOrphanedByUrl( const QString &table )
{
......
......@@ -81,6 +81,12 @@ public:
*/
void deleteAllRedundant( const QString &type );
/**
* Delete all entries from @p table with broken link to directories table. Currently
* had only sense on the urls table.
*/
void deleteOrphanedByDirectory( const QString &table );
/**
* Use on tables that link to non-existent entries in the urls table, for example
* urls_labels, statistics, lyrics. @param table must have a column named url.
......
......@@ -43,6 +43,10 @@ SqlRegistry::SqlRegistry( Collections::SqlCollection* collection )
// to those objects.
DatabaseUpdater databaseUpdater( m_collection );
// url entries without associated directory just stick around and cannot be processed
// by SqlScanResultProcessor. Delete them before checking tracks
databaseUpdater.deleteOrphanedByDirectory( "urls" );
// tracks with no associated url entry are useless, just a bunch of medatada with
// nothing to associate them to; remove those first
databaseUpdater.deleteOrphanedByUrl( "tracks" );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment