Bug 122480 - When deleting playlist that is a directory, the directory and all contents is deleted, not just the playlist entry
Summary: When deleting playlist that is a directory, the directory and all contents is...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.4-SVN
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-22 13:17 UTC by Greg Meyer
Modified: 2006-06-11 12:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Meyer 2006-02-22 13:17:54 UTC
Version:           1.4-SVN (using KDE KDE 3.5.1)
Installed from:    Unlisted Binary Package
Compiler:          GCC 4.0.2 
OS:                Linux

This was reported by a user in the help forum herehttp://amarok.kde.org/component/option,com_simpleboard/Itemid,57/func,view/id,11019/catid,8/limit,6/limitstart,0/

Essentially, an entry can be added to the list of playlists either by a playlist file, like a .m3u, or by specifying a directory.  If the playlist entry represents a directory, if you right-click and choose "delete playlist" the actual directory is removed as well as all the contents.

the delete function doesn't seem to be able to differentiate between deleting a playlist file from a dir, so it just 'rm -Rf %1'
Comment 1 Greg Meyer 2006-02-22 13:20:29 UTC
<a href="http://amarok.kde.org/component/option,com_simpleboard/Itemid,57/func,view/id,11057/catid,8/limit,6/limitstart,0/">Clickable link</a> for the forum post.
Comment 2 Mark Kretschmann 2006-02-22 13:30:33 UTC
Can't reproduce. If I try to select a directory and press "Open", I get an error dialog: "Please select the file to open."
Comment 4 Greg Meyer 2006-02-22 17:58:24 UTC
I thought so too at first, but if you merely highlight the directory in the 
file open dialog instead of enter it, you can then add it.

Greg
Comment 5 Alexandre Oliveira 2006-02-26 06:22:35 UTC
SVN commit 513697 by aoliveira:

If user set a dir as a playlist and then remove this playlist, the directory would be deleted, and that's not funny at all.
BUG: 122480


 M  +7 -0      playlistbrowser.cpp  


--- trunk/extragear/multimedia/amarok/src/playlistbrowser.cpp #513696:513697
@@ -1461,6 +1461,13 @@
     if ( button == KMessageBox::Continue )
     {
         // TODO We need to check which files have been deleted successfully
+        // Avoid deleting dirs. See bug #122480
+        for ( KURL::List::iterator it = items.begin(), end = items.end(); it != end; ++it ) {
+            if ( QFileInfo( (*it).path() ).isDir() ) {
+                it = items.remove( it );
+                continue;
+            }
+        }
         KIO::del( items );
         return true;
     }
Comment 6 Alexandre Oliveira 2006-02-27 05:23:48 UTC
SVN commit 513991 by aoliveira:

Backporting the fix for 122480 (When deleting playlist that is a directory, the directory and all contents is deleted, not just the playlist entry), as it was a quite serious bug.
CCBUG: 122480


 M  +2 -0      ChangeLog  
 M  +8 -1      src/playlistbrowser.cpp  


--- branches/stable/extragear/multimedia/amarok/ChangeLog #513990:513991
@@ -8,6 +8,8 @@
     * Support for libtunepimp 0.4. (BR 94988)
 
   BUGFIXES:
+    * When using a folder as playlist, deleting the playlist would delete
+      the folder and all files inside it. (BR 122480)
     * OSD was showing "No track playing" for tracks without metadata.
     * Smart Playlists with playcount or score related conditions wouldn't
       match all songs properly. (BR 97046)
--- branches/stable/extragear/multimedia/amarok/src/playlistbrowser.cpp #513990:513991
@@ -1009,6 +1009,13 @@
             urls.append( (*it)->xmlUrl() );
         }
         // TODO We need to check which files have been deleted successfully
+        // Avoid deleting dirs. See bug #122480
+        for ( KURL::List::iterator it = items.begin(), end = items.end(); it != end; ++it ) {
+            if ( QFileInfo( (*it).path() ).isDir() ) {
+                it = items.remove( it );
+                continue;
+            }
+        }
         KIO::del( urls );
         return true;
     }
@@ -1364,7 +1371,7 @@
     else
     {
         debug() << "not current!" << endl;
-	
+
 	//Remove any items in Listview that have the same path as this one
         //  Should only happen when overwriting a playlist
         QListViewItem *item = parent->firstChild();