Bug 366 - Music library scan can't handle directory that's all whitespace
: Music library scan can't handle directory that's all whitespace
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Misc
: 5.x or older
: Macintosh All
: P4 minor (vote)
: ---
Assigned To: Dan Sully
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-06-10 22:07 UTC by Bill Fenner
Modified: 2008-12-18 11:54 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Fenner 2004-06-10 22:07:42 UTC
The music folder scan goes into an infinite loop if you have a directory named "       ".  Yes, I know that's 
a weird thing to do, but iTunes did it for me because that's what the id3 tag said.

The problem is that URI->new() strips trailing whitespace, so URI->new("file:///mp3/foo/    ") turns 
into just looking at /mp3/foo again.

I looked at trying to url-escape the args to fixPath but then some other things started getting double-
escaped.  Maybe someone who knows this code better can help.  Just make a directory named "    " 
inside your music library.  The debugging ends up looking like

2004-06-10 21:30:59.3814 Descending into file:///big/mp3/billo/Brian%20Setzer%20Orchestra/, 
contains 1 items
2004-06-10 21:30:59.3827 numitems: 142
2004-06-10 21:30:59.3837 index: 0
2004-06-10 21:30:59.3852 *****fixed:                                to file:///big/mp3/billo/
Brian%20Setzer%20Orchestra/
2004-06-10 21:30:59.3861 *****base: /big/mp3/billo/Brian Setzer Orchestra/
2004-06-10 21:30:59.3870 itempath:                                and file:///big/mp3/billo/
Brian%20Setzer%20Orchestra/ made file:///big/mp3/billo/Brian%20Setzer%20Orchestra/
2004-06-10 21:30:59.3879 isList(file:///big/mp3/billo/Brian%20Setzer%20Orchestra/) == dir


Here is a hack of a patch to prevent this particular infinite loop.

Index: Slim/Utils/Scan.pm
===============================================================
====
RCS file: /cvsroot/slim/server/Slim/Utils/Scan.pm,v
retrieving revision 1.10
diff -u -r1.10 Scan.pm
--- Slim/Utils/Scan.pm	13 May 2004 17:57:36 -0000	1.10
+++ Slim/Utils/Scan.pm	11 Jun 2004 05:06:20 -0000
@@ -271,6 +271,15 @@
 	my $itempath = Slim::Utils::Misc::fixPath($item, $curdirState->path);
 	$::d_scan && msg("itempath: $item and " .  $curdirState->path . " made $itempath\n");
 
+	# XXX
+	# fixPath (really URI) strips trailing spaces from $item.
+	# if $item is all spaces, that means we just get the path again
+	# so break this loop.  This should be removed when fixPath
+	# gets fixed.
+	if ($curdirState->path eq $itempath) {
+		return 1;
+	}
+
 ######### If it's a directory or playlist and we're recursing, push it onto the stack, othwerwise add it 
to the list
 
 	$::d_scan && msg("isList(".$itempath.") == ".Slim::Music::Info::isList($itempath)."\n");
Comment 1 Bill Fenner 2004-10-30 23:23:17 UTC
This bug still exists in today's CVS HEAD.  It'd be nice to see the workaround committed.
Comment 2 Blackketter Dean 2004-10-31 06:39:04 UTC
Vidur, can you can consider this for 5.4?
Comment 3 Vidur Apparao 2004-11-03 14:58:53 UTC
Workaround committed on 11/3/04.
Comment 4 KDF 2004-11-09 11:28:20 UTC
in fact, looks like line 88 of Playlist.pm isn't even needed since the
setMode($client,'home'); call automatically goes to the "NOW_PLAYING" menu item
Comment 5 KDF 2004-11-09 11:28:54 UTC
argh...hate how this skips forward.  ignore that :)
Comment 6 Blackketter Dean 2005-03-11 14:20:52 UTC
Dan suggests that this is fixed in latest itunes.  if not, then the itunes xml importer needs to convert 
spaces in URLs to %20 encoding.

Comment 7 Dan Sully 2005-03-11 21:19:32 UTC
*** Bug 438 has been marked as a duplicate of this bug. ***
Comment 8 Blackketter Dean 2005-04-04 14:41:22 UTC
Bill: is this still happening  with the latest nightly with the latest version of iTunes?  If not, can you 
reopen the bug?  Thanks.
Comment 9 Chris Owens 2008-12-18 11:54:20 UTC
Routine bug db maintenance; removing old versions which cause confusion.  I apologize for the inconvenience.