Bug 5666 - Dir with a recognized suffix added with a wrong content type
: Dir with a recognized suffix added with a wrong content type
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Database
: 7.0
: PC SuSE Linux
: P2 normal (vote)
: 7.x
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-04 14:39 UTC by Nicolas JUSTIN
Modified: 2009-07-31 10:14 UTC (History)
0 users

See Also:
Category: ---


Attachments
Proposed fix (1.49 KB, patch)
2007-10-04 14:41 UTC, Nicolas JUSTIN
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas JUSTIN 2007-10-04 14:39:17 UTC
When browsing with "My Music/Music Folder" to a music folder which is like:

~/Music/
    +- album.flc/
        +- 01.flc
        +- 02.flc
        +- 03.flc

Where "album.flc" is a simple directory, and 01.flc, 02.flc and 03.flc are valid FLAC files.
If you browse the dir ~/Music through "My Music/Music Folder" feature, the "album.flc" is detected as a FLAC file, so it is added in the track list linked to the album "No Album" in the database. And you cannot go into it from the web interface since it is considered as a song.

This problem does not show up, whit scanner, but only from the "Music Folder".

Since it was my first bug tracking in SlimServer, I need to touch some files before finding it the Slim::Music::Info::typeFromPath method. I know the workaround (renaming the dir) is much more easy, but not as fun :-)
I think it is the most useless fix :-)
This bug is also present in the 6.5 branch.

Please find my fix below for trunk, it is nearly the same for the 6.5 branch:

Index: Slim/Music/Info.pm
===================================================================
--- Slim/Music/Info.pm  (revision 13549)
+++ Slim/Music/Info.pm  (working copy)
@@ -1195,6 +1195,15 @@
        # Remove the anchor if we're checking the suffix.
        my ($type, $anchorlessPath);

+       my $filepath;
+
+       if (isFileURL($fullpath)) {
+               $filepath = Slim::Utils::Misc::pathFromFileURL($fullpath);
+       } else {
+               $filepath = $fullpath;
+       }
+
+
        if ($fullpath && $fullpath !~ /\x00/) {

                # Return quickly if we have it in the cache.
@@ -1214,6 +1223,11 @@
                        # Force mp3 for protocol handlers
                        return 'mp3';
                }
+               elsif (-d $filepath) {
+                       # We want to test here if this a dir, before typeFromSuffix thinks
+                       # it is a valid file instead of a dir with a recognized suffix.
+                       $type = 'dir';
+               }
                else {

                        $anchorlessPath = Slim::Utils::Misc::stripAnchorFromURL($fullpath);
@@ -1230,14 +1244,6 @@
        # We didn't get a type from above - try a little harder.
        if ((!defined($type) || $type eq 'unk') && $fullpath && $fullpath !~ /\x00/) {

-               my $filepath;
-
-               if (isFileURL($fullpath)) {
-                       $filepath = Slim::Utils::Misc::pathFromFileURL($fullpath);
-               } else {
-                       $filepath = $fullpath;
-               }
-
                if ($filepath) {

                        $anchorlessPath = Slim::Utils::Misc::stripAnchorFromURL($filepath);
@@ -1255,10 +1261,6 @@
                                        $type = typeFromSuffix($anchorlessPath, $defaultType);
                                }

-                       } elsif (-d $filepath) {
-
-                               $type = 'dir';
-
                        } else {

                                # file doesn't exist, go ahead and do typeFromSuffix
Comment 1 Nicolas JUSTIN 2007-10-04 14:41:19 UTC
Created attachment 2213 [details]
Proposed fix

The same as in the report...
Comment 2 Andy Grundman 2008-06-08 07:33:12 UTC
This bug appears to already be fixed.  Please retest with the latest 7.1 and reopen if you still see it.
Comment 3 Chris Owens 2008-07-30 15:26:35 UTC
This bug has now been fixed in the 7.1 release version of SqueezeCenter!  Please download the new version from http://www.slimdevices.com if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 4 Chris Owens 2009-07-31 10:14:55 UTC
Reduce number of active targets for SC