Bug 115478 - amaroK scans hidden directories and the trash bin
Summary: amaroK scans hidden directories and the trash bin
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.3.5
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-01 15:59 UTC by Matthias Emanuel Thoemmes
Modified: 2006-08-07 09:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
strace of collection scanning process (49.30 KB, text/plain)
2005-12-07 21:48 UTC, Nick Leverton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Emanuel Thoemmes 2005-11-01 15:59:48 UTC
Version:           1.3.5 (using KDE KDE 3.4.2)
Installed from:    SuSE RPMs
OS:                Linux

If a directory with hidden subdirectories (dot as a prefix: .trash) is set in the collection preferences, amaroK scans through them. This includes the trash bin.

It is expected that amaroK doesn't include the trash bin. The media player shouldn't include hidden directories in the collection.
Comment 1 Dirk Mueller 2005-11-01 17:02:56 UTC
are you sure it does that? I've specifically added code in 1.3.4 to prevent it recursing into hidden subdirectories. 

where did you get the package from?

rpm -q --changelog amarok | head please

Comment 2 Matthias Emanuel Thoemmes 2005-11-01 20:27:47 UTC
Excuse me, I compiled amaroK 1.3.5 by myself. 
Configuration:

$ ./configure --prefix=/opt/kde3/ --enable-mysql --without-arts --without-opengl --without-libvisual --with-helix --with-mas
Comment 3 Nick Leverton 2005-12-07 00:19:51 UTC
I am using amarok 1.3.6 from Debian, which I backported myself from sid to sarge under KDE 3.4.2.  I also find that amarok scans dot-dirs from KDE and Gnome, so that I get three copies of almost all media files in the collection.  I can come up with the build options and versions if it would help.
Comment 4 Dirk Mueller 2005-12-07 03:05:46 UTC
SVN commit 486194 by mueller:

fix collection recursion
BUG: 115478


 M  +1 -1      collectionreader.cpp  


--- branches/stable/extragear/multimedia/amarok/src/collectionreader.cpp #486193:486194
@@ -231,7 +231,7 @@
 
         if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entry[0] != '.' )
         {
-            const QString file = QFile::decodeName( entry );
+            const QString file = dir + QFile::decodeName( entry );
 
             if( !m_incremental || !CollectionDB::instance()->isDirInCollection( file ) )
                 // we MUST add a '/' after the dirname
Comment 5 Nick Leverton 2005-12-07 13:14:02 UTC
Patch works well on 1.3.6 too, thankyou for the very quick fix!
Comment 6 Nick Leverton 2005-12-07 21:47:41 UTC
Sorry I spoke too soon, this has introduced a new problem.

There is now no recursive scanning of collections, only the top directory.  I've done an strace, attached, and it seems that the collection dirname is being doubly appended.
Comment 7 Nick Leverton 2005-12-07 21:48:04 UTC
Created attachment 13815 [details]
strace of collection scanning process

I only included lines 40,000 to 41,600 of strace in the interests of space and
privacy, but it shows the important part.  The first directory is statted at
line 101, the second at line 542.  You can see that each S_IFDIR entry is
statted again but with the collection dir doubly prefixed to the filename.  I
guess this is why directories aren't recursed into.
Comment 8 Dirk Mueller 2005-12-07 22:15:43 UTC
ok, reverted. 
Comment 9 Mark Kretschmann 2006-03-22 12:22:54 UTC
What's up with this report, I thought this was fixed?
Comment 10 Dirk Mueller 2006-03-22 13:11:08 UTC
I can not reproduce the issue so far, so a bit more information would be useful.. 

which directories do you list for scanning? and where does it start recursing into dot directories?

strace might help
Comment 11 Eckhart Wörner 2006-04-07 22:33:59 UTC
The bug is clearly reproducable with Amarok 1.4b2 (using Debian experimental packages).

I used the following steps to reproduce it:

1. created the following directory structure:
+ testfolder
  + .hidden
    + somefile.ogg

2. I now used the assistent to add "testfolder" to my music collection. In the assistent, the subfolder ".hidden" is not shown.
My amarokrc now looks like:
Collection Folders=/home/eckhart/Musik,/home/eckhart/testfolder

3. On rescanning, somefile.ogg appears in my collection (clearly identified by it's meta information).
Comment 12 Roland 2006-04-12 21:34:36 UTC
SVN commit 529214 by rolandg:

Skip hidden directories while scanning the collection

BUG: 115478


 M  +1 -0      ChangeLog  
 M  +2 -1      src/collectionreader.cpp  


--- branches/stable/extragear/multimedia/amarok/ChangeLog #529213:529214
@@ -8,6 +8,7 @@
     * Support for libtunepimp 0.4. (BR 94988)
 
   BUGFIXES:
+    * Skip hidden directories while scanning the collection. (BR115478)
     * Fix leak of file descriptors with embedded cover art. Patch by Shane
       King <kde@dontletsstart.com>. (BR 123472)
     * Stop collection folders being automatically removed. Instead, allow
--- branches/stable/extragear/multimedia/amarok/src/collectionreader.cpp #529213:529214
@@ -218,6 +218,7 @@
 
     for( dirent *ent; (ent = readdir( d )) && !isAborted(); ) {
         QCString entry (ent->d_name);
+        QCString entryname (ent->d_name);
 
         if ( entry == "." || entry == ".." )
             continue;
@@ -231,7 +232,7 @@
         if ( ! ( S_ISDIR( statBuf.st_mode ) || S_ISREG( statBuf.st_mode ) ) )
             continue;
 
-        if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entry[0] != '.' )
+        if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entryname[0] != '.' )
         {
             const QString file = QFile::decodeName( entry );
 
Comment 13 Roland 2006-04-12 21:35:25 UTC
SVN commit 529216 by rolandg:

Skip hidden directories while scanning the collection

CCBUG: 115478


 M  +1 -0      ChangeLog  
 M  +2 -1      src/collectionscanner/collectionscanner.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #529215:529216
@@ -9,6 +9,7 @@
   CHANGES:
 
   BUGFIXES:
+    * Skip hidden directories while scanning the collection. (BR115478)
     * Instead of cancelling collection organiziation operations when starting
       new one append to running one.
     * Correctly show &amp; in playlist 'Burn' right-click submenu. Patch by
--- trunk/extragear/multimedia/amarok/src/collectionscanner/collectionscanner.cpp #529215:529216
@@ -201,6 +201,7 @@
 
     for( dirent *ent; ( ent = readdir( d ) ); ) {
         QCString entry (ent->d_name);
+        QCString entryname (ent->d_name);
 
         if ( entry == "." || entry == ".." )
             continue;
@@ -214,7 +215,7 @@
         if ( ! ( S_ISDIR( statBuf.st_mode ) || S_ISREG( statBuf.st_mode ) ) )
             continue;
 
-        if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entry[0] != '.' )
+        if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entryname[0] != '.' )
         {
             const QString file = QFile::decodeName( entry );
 
Comment 14 Andreas Schwab 2006-08-07 01:27:21 UTC
This causes albums that start with a dot to be omitted from the collection.
Comment 15 Martin Aumueller 2006-08-07 09:41:44 UTC
You coulde use Amarok's 'organize collection' feature: it will move the artist '...And you will know us by the trail of dead' to the directory 'And you will know us by the trail of dead' and thereby solve your problems.