PDA

View Full Version : RE: Changes to Info.pm to deal with emptytracknumbe r fields



Reckase, Erik Nathan
2003-12-03, 15:09
Whoops. This is still bad, in the event that a non-numeric value is stored
in the track number. Here's a better fix:

diff -ubr Info.pm.old Info.pm
--- Info.pm.old Tue Dec 2 07:38:50 2003
+++ Info.pm Wed Dec 3 14:08:10 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. 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) && $trnum =~ /^\d+$/ &&
$seen[$trnum]) {
$duptracknum = 1;
last;
}
+
+ if (defined($trnum) && $trnum =~ /^\d+$/) {
$seen[$trnum]++;
+ }
}
if ($duptracknum) {
@uniq = sortByTrack(@uniq);