Bug 129018 - Amarok follows symlink - option to not do that
Summary: Amarok follows symlink - option to not do that
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-12 07:34 UTC by Manuel Amador (Rudd-O)
Modified: 2006-07-25 02:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Make amarok not follow symlinks (6.95 KB, patch)
2006-06-12 07:35 UTC, Manuel Amador (Rudd-O)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Amador (Rudd-O) 2006-06-12 07:34:09 UTC
Version:           1.4.0a (using KDE KDE 3.5.2)
Installed from:    Fedora RPMs
OS:                Linux

Amarok follows symlinks.  On collections that have folders of "favorite" songs stored as symlinks, this causes N songs to appear in the collection.  Thus, ratings for one song are inconsistent and spread among different files.

We need an option to avoid this.

Patch attached
Comment 1 Manuel Amador (Rudd-O) 2006-06-12 07:35:39 UTC
Created attachment 16564 [details]
Make amarok not follow symlinks

This patch enables amarok to skip symlinks when reading the collection.
Comment 2 Manuel Amador (Rudd-O) 2006-06-12 22:34:09 UTC
Further discussion at:

http://rudd-o.com/archives/2006/06/12/amarok-follows-symbolic-links-no-problem/
Comment 3 Alexandre Oliveira 2006-07-25 02:39:59 UTC
SVN commit 565974 by aoliveira:

Collection Scanner resolves symlinks, what avoids duplicating files when there's links that point to other folders inside of the 
collection. Please test, this might create problems.
BUG: 129018


 M  +12 -0     collectionscanner.cpp  


--- trunk/extragear/multimedia/amarok/src/collectionscanner/collectionscanner.cpp #565973:565974
@@ -27,6 +27,8 @@
 #include <iostream>
 
 #include <dirent.h>    //stat
+#include <limits.h>    //PATH_MAX
+#include <stdlib.h>    //realpath
 
 #include <taglib/audioproperties.h>
 #include <taglib/fileref.h>
@@ -150,6 +152,7 @@
 
     const QCString dir8Bit = QFile::encodeName( dir );
     struct stat statBuf;
+    struct stat statBuf_symlink;
     stat( dir8Bit, &statBuf );
 
     struct direntry de;
@@ -197,6 +200,8 @@
 
         if ( stat( entry, &statBuf ) != 0 )
             continue;
+        if ( lstat( entry, &statBuf_symlink ) != 0 )
+            continue;
 
         // loop protection
         if ( ! ( S_ISDIR( statBuf.st_mode ) || S_ISREG( statBuf.st_mode ) ) )
@@ -204,6 +209,13 @@
 
         if ( S_ISDIR( statBuf.st_mode ) && m_recursively && entry.length() && entryname[0] != '.' )
         {
+            if ( S_ISLNK( statBuf_symlink.st_mode ) ) {
+                char nosymlink[PATH_MAX];
+                if ( realpath( entry, nosymlink ) ) {
+                    debug() << entry << " is a symlink. Using: " << nosymlink << endl;
+                    entry = nosymlink;
+                }
+            }
             const QString file = QFile::decodeName( entry );
 
             bool isInCollection = false;