PDA

View Full Version : No Subject



Jason Holtzapple
2004-04-23, 10:01
I think this checkin is still going to cause problems because eval
can't trap a 'use' properly.

Also the symbol store_fd is imported but not used. It should be store.
Also, there's no need to eval twice to see if Storable's available.


I think the patch attached will sort this out.


Index: ShoutcastBrowser.pm
================================================== =================
RCS file: /home/cvs/cvsroot/slim/server/Plugins/ShoutcastBrowser.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ShoutcastBrowser.pm 22 Apr 2004 00:00:49 -0000 1.6
+++ ShoutcastBrowser.pm 23 Apr 2004 16:24:57 -0000 1.7
@@ -215,7 +215,9 @@
$legit_genres{$g}++;
}

-use Storable qw(store_fd retrieve_fd);
+eval {
+ use Storable qw(store_fd retrieve_fd);
+};
use Fcntl qw(:DEFAULT :flock);
use File::Spec::Functions qw(:ALL);
use Slim::Control::Command;
@@ -1240,6 +1242,7 @@

sub add_recent_stream
{
+if ($have_storable) {
my ($client, $new, $bitrate, $data_ref) = @_;

# Another client may have changed it since our last access
@@ -1272,6 +1275,7 @@
my $rv = store([ $stream_data{$recent_name}, \@recent ], $recent_filename);
warn "ShoutcastBrowser: Storing recent streams failed.\n" unless $rv;
$fh->close;
+}
}


--- ShoutcastBrowser.pm.bak Fri Apr 23 09:54:54 2004
+++ ShoutcastBrowser.pm Fri Apr 23 09:56:57 2004
@@ -215,9 +215,13 @@
$legit_genres{$g}++;
}

+my $have_storable = 0;
eval {
- use Storable qw(store_fd retrieve_fd);
+ require Storable;
+ import Storable qw(store retrieve_fd);
};
+$have_storable = 1 unless $@;
use Fcntl qw(:DEFAULT :flock);
use File::Spec::Functions qw(:ALL);
use Slim::Control::Command;
@@ -228,7 +232,6 @@
use LWP::Simple;
use HTML::Entities;
my $have_zlib = eval 'use Compress::Zlib; 1;';
-my $have_storable = eval 'use Storable; 1;';

sub getDisplayName {return string('PLUGIN_SHOUTCASTBROWSER_MODULE_NAME')}

Robert Moser
2004-04-23, 12:35
Jason Holtzapple wrote:

> I think this checkin is still going to cause problems because eval
> can't trap a 'use' properly.

> my $have_zlib = eval 'use Compress::Zlib; 1;';
> -my $have_storable = eval 'use Storable; 1;';

Wouldn't the same be true of that $have_zlib part?

Jason Holtzapple
2004-04-23, 13:36
Yes, you're right ... if we're going to clean up one we should do the
other as well.

patch against CVS attached.

--Jason

Robert Moser wrote:
> Jason Holtzapple wrote:
>
>> I think this checkin is still going to cause problems because eval
>> can't trap a 'use' properly.
>
>
>> my $have_zlib = eval 'use Compress::Zlib; 1;';
>> -my $have_storable = eval 'use Storable; 1;';
>
>
> Wouldn't the same be true of that $have_zlib part?
>