Bug in Sql Registry?

Maximilian Kossick maximilian.kossick at googlemail.com
Mon Apr 5 12:32:42 CEST 2010


On Sun, Apr 4, 2010 at 10:01 PM, Casey Link <unnamedrambler at gmail.com> wrote:
> Ok, so I've discovered some erroneous behavior with SqlCollection's
> registry system.
>
>
> I have a collection folder which I use for testing amarok, so I only
> enable this folder when I want to do testing. When I enable this
> folder I do a full rescan.
>
> (enable/disabling done in Amarok Collection folder config)
>
> When I'm done testing I disable this folder.
>
> Later, when I try to browse that directory via the FileBrowser,
> CollectionManager is determining that the tracks belong to
> SqlCollection, because SqlCollection::trackForUrl() is finding them in
> its registry.
>
> It follows the path:
>
> SqlCollection::trackForUrl( const KUrl &url )
> SqlRegistry::getTrack( const QString &url )
> SqlTrack::getTrack( int deviceid, const QString &rpath,
> Collections::SqlCollection *collection )
>
> In this method (the last one listed), it performs an sql query where
> it gets the result (sample):
>
> BEGIN: static Meta::TrackPtr Meta::SqlTrack::getTrack(int, const
> QString&, Collections::SqlCollection*)
> amarok:      result ("-1", "./home/ramblurr/Downloads/mp3/yet/Adam
> Freedman - Best Laid Plans (Gone Wrong)/Adam Freedman - Best Laid
> Plans (Gone Wrong)/01-Truly Blind.mp3",
> "amarok-sqltrackuid://6d994d5ce0b7ef608c34bf4cad4bfd1c", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
> "", "", "", "", "", "", "", "", "", "", "", "")
>
> Hence, it returns an SqlTrack with EMPTY tags (see
> http://imagebin.ca/view/2NljMyn.html), when really.. I want
> SqlCollection::trackForUrl to return null, so I can get a
> MetaFile::Track().
>
> What it comes down to is the registry isn't deleting tracks from
> itself when their corresponding folders are removed. There might be
> good reason for this, but can we check that before returning an
> SqlTrack it is contained in the current sqlcollection's folders?
> i.e.:
> foreach ( folder, SqlCollectionFolders {
> if( SqlTrack->path.contains( folder)
>  return SqlTrack
> }
> return 0

The analysis is wrong.  The track is not in the registry anymore,
otherwise SqlTrack::getTrack would never be called. The real issue is
that the LEFT JOIN on the tracks table in
SqlMeta::getTrackJoinConditions should be an INNER JOIN.


More information about the Amarok-devel mailing list