[Slim-Checkins] r33701 - /7.7/trunk/server/Slim/Utils/DbCache.pm

[email protected]
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: mherger
Date: Sun Nov 13 03:45:31 2011
New Revision: 33701

URL: http://svn.slimdevices.com/slim?rev=33701&view=rev
Log:
Bug: n/a
Description: catch 'never' expiry time - Canonicalize_Expiration_Time doesn't like it. Eval Canonicalize_Expiration_Time in case it would dislike other values, fall back to default (1h)

Modified:
    7.7/trunk/server/Slim/Utils/DbCache.pm

Modified: 7.7/trunk/server/Slim/Utils/DbCache.pm
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Slim/Utils/DbCache.pm?rev=33701&r1=33700&r2=33701&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Utils/DbCache.pm (original)
+++ 7.7/trunk/server/Slim/Utils/DbCache.pm Sun Nov 13 03:45:31 2011
@@ -156,11 +156,21 @@
 sub _canonicalize_expiration_time {
 	my ( $expiry ) = @_;
 	
+	# see below - 'never' would crash 
+	$expiry = -1 if $expiry eq 'never';
+	
 	if ( $expiry && $expiry !~ /^[\-]*\d+$/ ) {
-		#Slim::Utils::Log::logBacktrace($expiry);
-		
 		# Not a number, need to canonicalize it
-		$expiry = Cache::BaseCache::Canonicalize_Expiration_Time($expiry);
+		# sometimes this fails on existing code, eg. with 'never'?
+		$expiry = eval { Cache::BaseCache::Canonicalize_Expiration_Time($expiry) };
+		
+		if ($@) {
+			require Slim::Utils::Log;
+			Slim::Utils::Log::logBacktrace($@);
+			Slim::Utils::Log->logger('server')->error('Falling back to default expiry time: ' . DEFAULT_EXPIRES_TIME);
+			
+			$expiry = DEFAULT_EXPIRES_TIME;
+		}
 	}
 
 	# "If value is less than 60*60*24*30 (30 days), time is assumed to be
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.