[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
This commit is contained in:
kohsuke committed 2009-09-21 23:46:47 +00:00
1 parent b8f2b7949d
commit 66f157955a
1 file changed
+27 -10
@@ -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;
}