From 66f157955a8effcfc8d6e3653a08dbcd3f4fe751 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 21 Sep 2009 23:46:47 +0000 Subject: [PATCH] [FIXED HUDSON-4353] we should now be able to update bundled plugins. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21979 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/model/UpdateCenter.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index ccd2e7d3e2..6b6126e260 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -303,7 +303,10 @@ public class UpdateCenter extends AbstractModelObject { if(data==null) return false; for (PluginWrapper pw : Hudson.getInstance().getPluginManager().getPlugins()) { - if(pw.getUpdateInfo() !=null) return true; + if(!pw.isBundled() && pw.getUpdateInfo()!=null) + // do not advertize updates to bundled plugins, since we generally want users to get them + // as a part of hudson.war updates. This also avoids unnecessary pinning of plugins. + return true; } return false; } @@ -804,15 +807,7 @@ public class UpdateCenter extends AbstractModelObject { try { LOGGER.info("Starting the installation of "+getName()+" on behalf of "+getUser().getName()); - URL src = getURL(); - - config.preValidate(this, src); - - File dst = getDestination(); - File tmp = config.download(this, src); - - config.postValidate(this, tmp); - config.install(this, tmp, dst); + _run(); LOGGER.info("Installation successful: "+getName()); status = new Success(); @@ -823,6 +818,18 @@ public class UpdateCenter extends AbstractModelObject { } } + protected void _run() throws IOException { + URL src = getURL(); + + config.preValidate(this, src); + + File dst = getDestination(); + File tmp = config.download(this, src); + + config.postValidate(this, tmp); + config.install(this, tmp, dst); + } + /** * Called when the download is completed to overwrite * the old file with the new file. @@ -914,6 +921,16 @@ public class UpdateCenter extends AbstractModelObject { return plugin.getDisplayName(); } + @Override + public void _run() throws IOException { + super.run(); + + // if this is a bundled plugin, make sure it won't get overwritten + PluginWrapper pw = plugin.getInstalled(); + if (pw!=null && pw.isBundled()) + pw.doPin(); + } + protected void onSuccess() { pm.pluginUploaded = true; }