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