[Slim-Checkins] r11183 - /trunk/server/Slim/Utils/PluginManager.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Fri Jan 12 15:56:43 PST 2007


Author: adrian
Date: Fri Jan 12 15:56:43 2007
New Revision: 11183

URL: http://svn.slimdevices.com?rev=11183&view=rev
Log:
Bug: N/A
Description: reparse install.xml files if one is newer than the plugin cache

Modified:
    trunk/server/Slim/Utils/PluginManager.pm

Modified: trunk/server/Slim/Utils/PluginManager.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/PluginManager.pm?rev=11183&r1=11182&r2=11183&view=diff
==============================================================================
--- trunk/server/Slim/Utils/PluginManager.pm (original)
+++ trunk/server/Slim/Utils/PluginManager.pm Fri Jan 12 15:56:43 2007
@@ -9,7 +9,6 @@
 
 # TODO:
 #
-# * Check plugin cache timestamp vs XML files, and load newer.
 # * Enable plugins that OP_NEEDS_ENABLE
 # * Disable plugins that OP_NEEDS_DISABLE 
 # 
@@ -71,17 +70,17 @@
 sub init {
 	my $class = shift;
 
-	# Check to see if we're starting from scratch, 
-	# or if we've been run before.
-	if (!-r $class->pluginCacheFile) {
-
-		$log->info("No plugin cache file exists - finding shipped plugins.");
-
-		$class->findInstalledPlugins;
+	my ($manifestFiles, $newest) = $class->findInstallManifests;
+
+	# parse the manifests if no cache file or it is older than newest install.xml file
+	if (!-r $class->pluginCacheFile || (stat($class->pluginCacheFile))[9] < $newest) {
+
+		$log->info("Reparsing plugin manifests - new manifest found.");
+
+		$class->readInstallManifests($manifestFiles);
 
 	} else {
 
-		# XXXX - need to check for newer versions of the install.xml files.
 		if (!$class->loadPluginCache) {
 
 			$class->checkPluginVersions;
@@ -135,8 +134,11 @@
 	return 1;
 }
 
-sub findInstalledPlugins {
-	my $class = shift;
+sub findInstallManifests {
+	my $class = shift;
+
+	my $newest = 0;
+	my @files;
 
 	# Only find plugins that have been installed.
 	my $iter = File::Next::files({
@@ -149,6 +151,21 @@
 	}, @pluginDirs);
 
 	while ( my $file = $iter->() ) {
+
+		my $mtime = (stat($file))[9];
+		$newest = $mtime if $mtime > $newest;
+
+		push @files, $file;
+	}
+
+	return (\@files, $newest);
+}
+
+sub readInstallManifests {
+	my $class = shift;
+	my $files = shift;
+
+	for my $file (@{$files}) {
 
 		my ($pluginName, $installManifest) = $class->_parseInstallManifest($file);
 



More information about the checkins mailing list