Don't delete whole folder when deleting a track

Authored by wbauer on Sep 20 2019, 9:09 AM.

Description

Don't delete whole folder when deleting a track

SqlCollectionLocation::moodFile() tries to replace the filename's
extension with ".mood" (and prepend a '.') to get the Url of the
moodfile.
But it does that *after* the filename has already been removed from the
Url, so QUrl::fileName() gives an empty string and the end result is
actually "/path/to/folder/." which depicts the containing folder.

As a result, when Amarok tries to delete the corresponding moodfile
after a track is deleted, the whole folder gets deleted instead.

To fix this, save the filename in a temporary variable before removing
it, and use that for generating the new filename.

BUG: 411760
Differential Revision: https://phabricator.kde.org/D24040

Details