From 8ec1d3d2795454688e893fb043a75ecdd2153fca Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sun, 7 Jan 2018 22:38:13 +0000
Subject: [PATCH v1 3/4] PluginHandler.installDownloadedPlugins: check
downloaded plugin is valid *before* we delete any existing one
the previous behaviour could turn out to be extremely annoying
---
src/org/openstreetmap/josm/plugins/PluginHandler.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/org/openstreetmap/josm/plugins/PluginHandler.java b/src/org/openstreetmap/josm/plugins/PluginHandler.java
index c36a3a664..09c900140 100644
a
|
b
|
public final class PluginHandler {
|
1255 | 1255 | final String filePath = updatedPlugin.getPath(); |
1256 | 1256 | File plugin = new File(filePath.substring(0, filePath.length() - 4)); |
1257 | 1257 | String pluginName = updatedPlugin.getName().substring(0, updatedPlugin.getName().length() - 8); |
1258 | | if (plugin.exists() && !plugin.delete() && dowarn) { |
1259 | | Logging.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString())); |
1260 | | Logging.warn(tr("Failed to install already downloaded plugin ''{0}''. " + |
1261 | | "Skipping installation. JOSM is still going to load the old plugin version.", |
1262 | | pluginName)); |
1263 | | continue; |
1264 | | } |
1265 | 1258 | try { |
1266 | 1259 | // Check the plugin is a valid and accessible JAR file before installing it (fix #7754) |
1267 | 1260 | new JarFile(updatedPlugin).close(); |
… |
… |
public final class PluginHandler {
|
1272 | 1265 | } |
1273 | 1266 | continue; |
1274 | 1267 | } |
| 1268 | if (plugin.exists() && !plugin.delete() && dowarn) { |
| 1269 | Logging.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString())); |
| 1270 | Logging.warn(tr("Failed to install already downloaded plugin ''{0}''. " + |
| 1271 | "Skipping installation. JOSM is still going to load the old plugin version.", |
| 1272 | pluginName)); |
| 1273 | continue; |
| 1274 | } |
1275 | 1275 | // Install plugin |
1276 | 1276 | if (!updatedPlugin.renameTo(plugin) && dowarn) { |
1277 | 1277 | Logging.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", |