D24040: Don't delete whole folder when deleting a track

Wolfgang Bauer noreply at phabricator.kde.org
Wed Sep 18 07:53:47 BST 2019


wbauer created this revision.
wbauer added a reviewer: Amarok.
wbauer added a project: Amarok.
Herald removed a project: Amarok.
Herald added a subscriber: amarok-devel.
wbauer requested review of this revision.

REVISION SUMMARY
  `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

TEST PLAN
  Delete a track from the local collection (right-click->"Delete tracks" or "Move to trash").
  Only the selected track gets deleted now, previously it deleted all other files in the containing folder as well.
  
  Debug output I added locally confirms that the generated path is now as expected, i.e. "/path/to/folder/.xxx.mood" instead of "path/to/folder/.".

REPOSITORY
  R181 Amarok

REVISION DETAIL
  https://phabricator.kde.org/D24040

AFFECTED FILES
  src/core-impl/collections/db/sql/SqlCollectionLocation.cpp

To: wbauer, #amarok
Cc: amarok-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/amarok-devel/attachments/20190918/f5ab15f5/attachment.html>


More information about the Amarok-devel mailing list