[freenet-cvs] r15746 - trunk/freenet/src/freenet/pluginmanager

nextgens at freenetproject.org nextgens at freenetproject.org
Sat Nov 10 22:15:56 UTC 2007


Author: nextgens
Date: 2007-11-10 22:15:56 +0000 (Sat, 10 Nov 2007)
New Revision: 15746

Modified:
   trunk/freenet/src/freenet/pluginmanager/PluginManager.java
Log:
Fix a serious bug in the plugin-loading code, preventing some plugins to be downloaded

Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java	2007-11-10 20:15:32 UTC (rev 15745)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java	2007-11-10 22:15:56 UTC (rev 15746)
@@ -426,11 +426,11 @@
 		/* check if name is a local file. */
 		File pluginFile = new File(name);
 		if (pluginFile.exists() && pluginFile.isFile()) {
-			try {
-				pluginUrl = pluginFile.toURI().toURL();
-			} catch (MalformedURLException e) {
-				throw new PluginNotFoundException("can not convert local path");
-			}
+                        try {
+                            pluginUrl = pluginFile.toURI().toURL();
+                        } catch (MalformedURLException e) {
+                            throw new PluginNotFoundException("can not convert local path");
+                        }
 		} else {
 			/* check if name contains a URL. */
 			try {
@@ -463,7 +463,7 @@
 		if (logMINOR) {
 			Logger.minor(this, "plugin file " + pluginFile.getAbsolutePath() + " exists: " + pluginFile.exists());
 		}
-		if (!pluginFile.exists()) {
+		if (!pluginFile.exists() || pluginFile.length() == 0) {
 			File tempPluginFile = null;
 			OutputStream pluginOutputStream = null;
 			URLConnection urlConnection = null;
@@ -491,13 +491,7 @@
 				Closer.close(pluginOutputStream);
 				Closer.close(pluginInputStream);
 			}
-			/* move temp jar to final jar. */
-			if (pluginFile.exists()) {
-				if (!pluginFile.delete()) {
-					Logger.error(this, "could not remove old plugin file");
-					throw new PluginNotFoundException("could not remove old plugin file");
-				}
-			}
+                        
 			if (!tempPluginFile.renameTo(pluginFile)) {
 				Logger.error(this, "could not rename temp file to plugin file");
 				throw new PluginNotFoundException("could not rename temp file to plugin file");




More information about the cvs mailing list