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

[email protected]
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: mherger
Date: Mon Nov 14 02:50:17 2011
New Revision: 33702

URL: http://svn.slimdevices.com/slim?rev=33702&view=rev
Log:
Bug: n/a
Description: make sure cache DB file names are not longer than 8 characters. Use namespace's hash value as part of the shortened file name.

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=33702&r1=33701&r2=33702&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Utils/DbCache.pm (original)
+++ 7.7/trunk/server/Slim/Utils/DbCache.pm Mon Nov 14 02:50:17 2011
@@ -186,8 +186,14 @@
 sub _get_dbfile {
 	my $self = shift;
 	
-	# XXX - namespace should not be longer than 8 characters on Windows, as it was causing DB corruption
-	return catfile( $self->{root}, $self->{namespace} . '.db' );
+	my $namespace = $self->{namespace};
+	
+	# namespace should not be longer than 8 characters on Windows, as it was causing DB corruption
+	if ( main::ISWINDOWS && length($namespace > 8) ) {
+		$namespace = lc(substr($namespace, 0, 4)) . substr(Digest::MD5::md5_hex($namespace), 0, 4);
+	}
+	
+	return catfile( $self->{root}, $namespace . '.db' );
 }
 
 sub _init_db {
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.