PDA

View Full Version : Changes to Info.pm to deal with empty tracknumber fields



Reckase, Erik Nathan
2003-12-03, 11:53
The first time I tried to use the server, I opened a directory with a number
of full-album mp3 files, all of which had no track number defined. I got a
few errors with this, so I fixed 'em. There was also some redundant code in
the check for cache loop.

This is the first time I've submitted a fix, so if you want it in a
different format, please let me know.

Regards,
Erik


diff -ubr Info.pm.old Info.pm
--- Info.pm.old Tue Dec 2 07:38:50 2003
+++ Info.pm Wed Dec 3 10:45:51 2003
@@ -815,7 +815,7 @@

my $item = cacheItem($file, $tagname);

- # we'll update the cache if we don't have a valid title in the cache
+ # update the cache if the tag is not defined in the cache
if (!defined($item)) {
# defer cover information until needed
if ($tagname =~ /^(COVER|COVERTYPE)$/) {
@@ -826,14 +826,13 @@
updateCoverArt($file,'thumb');
$item = cacheItem($file, $tagname);
# load up item information if we've never seen it or we
haven't loaded the tags
- } elsif ($tagname =~ /^(THUMB|THUMBTYPE)$/) {
- updateCoverArt($file,1);
- $item = cacheItem($file, $tagname);
- # load up item information if we've never seen it or we
haven't loaded the tags
} elsif (!exists($infoCache{$file}) || !cacheItem($file,
'TAG')) {
$::d_info && Slim::Utils::Misc::bt();
$::d_info && Slim::Utils::Misc::msg("cache miss for
$file\n");
$item = readTags($file)->{$tagname};
+ } else {
+ # This tag is not defined for this file. Explicitly
return undef.
+ $item = undef;
}
}
return $item;
@@ -1292,11 +1291,14 @@
my @seen = ();
foreach my $item (@uniq) {
my $trnum = trackNumber($item);
- if ($trnum && $seen[$trnum]) {
+ if (defined($trnum) && $seen[$trnum]) {
$duptracknum = 1;
last;
}
+
+ if (defined($trnum)) {
$seen[$trnum]++;
+ }
}
if ($duptracknum) {
@uniq = sortByTrack(@uniq);diff -ubr Info.pm
Info.pm.old